DocsIntegrations

How to track lead source in Contact Form 7

A Contact Form 7 enquiry tells you what the visitor wrote. It does not tell you whether they came from a Google ad, a newsletter or a search result.

TrackLeadSource fills five hidden fields in your form with the source, medium and campaign of the visit, the sources the visitor came from in order, and the pages they viewed. Each enquiry arrives with that context, so you can see it with the enquiry and in anything the form is connected to.

With the source saved on every enquiry, you can see which channels bring leads and, once sales results are added in your CRM, which bring customers. Setup takes one snippet and five hidden fields in your form.

Install the snippet

  1. Sign in to your TrackLeadSource dashboard and open Websites, then your website.
  2. Go to the Installation tab and copy the snippet.
  3. Paste it before the closing </head> tag on every page, including the page with your form.
<script async src="https://app.trackleadsource.com/tls.js" data-site-id="tls_your_site_id"></script>

Add the hidden fields

  1. In WordPress, go to Contact > Contact Forms and open your form.
  2. Open the Form tab.
  3. Add the five lines below above the submit button.
  4. Click Save.
[hidden tls_source]
[hidden tls_medium]
[hidden tls_campaign]
[hidden tls_channel_path]
[hidden tls_page_path]

The Form tab in Contact Form 7 with five hidden tls_ fields above the submit buttonThe Form tab with the five hidden fields added

The names must match exactly. The snippet fills the fields when the page loads, so you do not set a value.

FieldWhat it holds
tls_sourceSource of the last recorded visit
tls_mediumMedium of that visit
tls_campaignCampaign of that visit
tls_channel_pathSources the visitor came from, in order
tls_page_pathPages the visitor viewed, in order

Add the values to your email

Contact Form 7 only puts the fields in an email if you ask.

  1. Open the Mail tab of the same form.
  2. Add the five lines below to the Message body.
  3. Click Save.
Source: [tls_source]
Medium: [tls_medium]
Campaign: [tls_campaign]
Source journey: [tls_channel_path]
Pages visited: [tls_page_path]

The Mail tab in Contact Form 7 with the TrackLeadSource mail tags in the message bodyThe Mail tab with the mail tags in the message body

If enquiries go to a CRM or spreadsheet through another plugin, map the five fields there too.

Send a test enquiry

  1. Add the bold part to the end of your website address and open it: example.com/?utm_source=test&utm_medium=cpc&utm_campaign=autumn
  2. Click through to the page with your form and submit it.
  3. Open the email and check that the source is test, the medium is cpc and the campaign is autumn.

If every field says TrackLeadSource inactive, the site ID in the snippet is wrong or the domain of the page does not match the website in your dashboard.

Support

If you have any questions, don’t hesitate to reach out to hello@trackleadsource.com.

Know the story behind your next enquiry