Be more sophisticated when categorising visitors who complete web forms. This ‘How to’ blog post takes you through the steps.

Using Google Tag Manager to classify web site traffic based on marketing source for Salesforce lead source integration

If you have lead forms on your web site you may want to be slightly more sophisticated than categorising all visitors who completed those web forms as having a lead source of ‘Website’.  For example, it is very likely that those visitors who turn into leads have responded to some marketing activity like an email or PPC campaign and viewed a landing page instrumented with your marketing parameters, e.g.

In these cases you may want to classify the lead source as ‘Email’ or ‘Paid Search’ reflecting the original source of the lead even though your web site form is the vehicle for the lead information.

The following process is an example of how to leverage GTM to integrate Salesforce lead source to original marketing campaign click through:

  1. In Google Tag Manager create new user-defined variable

Name = mmc (or your choice)

Type = URL

Component Type = Query

Query Key = cm_mmc (or your campaign parameter)

Google Tag Manager Screen 1

In the example above the variable cm_mmc will be populated with the value of the cm_mmc parameter, e.g. Silverpop-_-City_Break_Campaign-_-Email-_-Milan+City+break.

  1. Now that we have the landing page marketing tracking code in a GTM variable we can parse it to create a cookie that stores the source of the clickthrough. In the above example we want the cookie, which I have named leadSource, to contain ‘Email’.  Our campaign landing page email links have the ESP (Silverpop) as the first parameter in the campaign tracking so I create a lookup table to map the actual values to the values required in Salesforce. I create a custom tag to create the cookie ,and fire it when the mmc variable exists :

Google Tag Manager Screen 290216 - 2


  1. In Google Tag Manager create a variable that extracts the value of the leadSource cookie. I have chosen the name the GTM variable ‘leadSource’:

Google Tag Manager Screen 290216 - 3


  1. The final step, on the page where your Salesforce lead gen form exists, is to set the value of the hidden form field (called ‘lead_source’) that passes the data to Salesforce to the value of the leadSource cookie. Once again I use a custom tag to perform the required operation and fire it on the pages where the lead gen forms appear:

Google Tag Manager Screen 290216 - 4

That’s it! Now when a website visitor completes the Salesforce lead gen form on the site the lead source in Salesforce will be reported as the original campaign click through source rather than all being classified as ‘website’.

If you have any concerns with the set up of your analytics, or would like experts to validate the quality of the data being sent to Google Analytics or another analytics package, let us know so we can perform a tag audit on your site and give you the piece of mind you need when making important marketing decisions.