Tracking UTM parameters in Salesforce Web-to-Lead Forms

This guide shows you how to track UTM parameters in Salesforce Web-to-Lead forms.

Salesforce Web-to-Lead forms are great at creating leads in Salesforce upon each submission. But they don’t tell you where your leads come from.

  • What websites referred them?
  • Which Adwords keyword brought them to your site?
  • Which Facebook ad campaign converted them?

Overview of tracking UTM parameters in Salesforce Web-to-Lead forms

In this article we’re going to explain how you can achieve this and have a section like this for each of your Leads:

Example of tracking UTM parameters in Salesforce Web-to-Lead forms

Example of tracking UTM parameters in Salesforce Web-to-Lead forms

You’ll also be able to build Salesforce dashboards with UTM information.
As a result, you’ll see which campaigns generated the most sales:

Salesforce report breaking out the number of qualified leads by Adwords campaign

Salesforce report breaking out the number of qualified leads by Adwords campaign

Let’s say this is your Web-to-Lead form:

This is just an example – yours will look differently.

To bring UTM fields to Salesforce, you need to do three things:

  1. Add new fields to Salesforce that will store these UTM fields.
  2. Add these fields to your Web-to-Lead forms (and make them hidden).
  3. Add some JavaScript code to your page. This code will grab the UTM parameters and put them inside the hidden fields.

Step 1 – Add new fields to Salesforce

First, you need to add five new custom fields to Salesforce: UTM Source, UTM Medium, UTM Term, UTM Campaign, UTM Content.

JavaScript code from step 3 will fill in these fields with appropriate values.

To create these fields, go to Salesforce – Setup. Then search for “Lead” and select “Fields” from the menu:

Salesforce Lead fields search screenshot

Salesforce Lead fields search screenshot

Then scroll down to “Lead Custom Fields & Relationships” and click “New”:

Custom Lead fields in Salesforce

Custom Lead fields in Salesforce

Choose field type “Text”:

Salesforce - Choose new custom field type

Salesforce – Choose new custom field type

Set “Field label” to “UTM Source”, and Length to 255 (Salesforce fills in Field Name for you):

Set UTM source fields parameters in Salesforce

Set UTM source fields parameters in Salesforce

Click “Next”, and then “Save & New”.

Repeat the process and create another four fields:

  • UTM Medium
  • UTM Term
  • UTM Campaign
  • UTM Content

If you also want to know the source/medium/term/etc of each opportunity or account, do the following:

  1. Create the same fields for the Opportunity and/or Account object. You can do it in Setup – Opportunities – Fields, and Setup – Accounts – Fields.
  2. Go to Setup – Lead – Fields again, and click the button “Map Lead Fields”:
Salesforce - Map UTM fields from Lead to other objects

Salesforce – Map UTM fields from Lead to other objects

On that page, you will be able to map Lead fields to the corresponding Account/Opportunity fields. As a result, Account/Opportunity will receive UTM fields during lead conversion.

Step 2 – Add new fields to the forms

During step 1, you’ve created the custom fields to store UTM parameters in Salesforce. Now we’re going to add the same fields to your Web-to-Lead forms.

Generate the code for new fields in Salesforce

To do this, go to Salesforce – Setup – Web-to-Lead, and click “Create Web-to-Lead Form”:

Salesforce Web-to-lead form create button

Salesforce Web-to-lead form create button

Find the UTM fields you have just created in the “Available fields” section. Then, move them to “Selected Fields” using the arrow buttons between these sections.

Click “Generate”, and Salesforce will create a new Web-to-Lead form for you:

Sample Salesforce Web-to-Lead form

Sample Salesforce Web-to-Lead form

Don’t worry, you don’t need to replace your existing forms with this new form.

You just need to:
a) extract UTM fields from this new form, and
b) put them inside the existing Web-to-lead forms on your website.

Inside this newly generated form, you should be able to see block of code like this one:

Put the new fields’ code in your form(s)

Take the input name (e.g. 00N5800000Bew3F) and put it inside this template::

In this example, the input name is 00N5800000Bew3F, but in your form it will be different.

 

Repeat the process for all five fields, and as a result, you will have a block of code like this:

In this example, the input name is 00N5800000Bew3F, but in your form, it will be different.

 

Then put it inside your Web-to-Lead form, just above the closing </form> tag:

 

Congratulations! You have completed the most time-consuming steps, 1 & 2. Only one more step to go!
By now, you already have UTM fields both in Salesforce and your forms.
Plus, these fields get automatically synchronized. So you don’t need to worry about that.
There’s just one missing piece left. You need to insert the code that will populate these fields with actual UTM values.

Step 3 – Populate hidden fields with values (using JavaScript)

As a final step, put this JavaScript code somewhere on your page:

 

You can put it inside a Google Tag Manager tag if you like.

Congratulations! You have completed the most time-consuming steps, 1 & 2. Only one more step to go!
By now, you already have UTM fields both in Salesforce and your forms.
Plus, these fields get automatically synchronized. So you don’t need to worry about that.
There’s just one missing piece left. You need to insert the code that will populate these fields with actual UTM values.

Bonus step 4

If you’ve implemented this guide, you’re already ahead of most marketers out there.

If you want to get one step further, you can implement GA Connector – a tool that allows you to know even more about your clients.

You see, tracking just the UTM parameters has its limitations:

  • It doesn’t work if the user left the page, and then came back from bookmarks or by simply typing your domain. For such leads, the UTM information would be lost (unless you use a tool like GA Connector).
  • Same with multi-page websites: if your user landed on one page, but the actual form submission happen on another page, the UTM information would be lost.
  • This approach only tells you which channel converted the lead. But sometimes it takes more than one visit to seal the deal. You user could have found you through Google but came back through Facebook remarketing. Does it make sense to attribute the conversion only to remarketing?
  • This approach doesn’t allow to track organic Google search. You can’t put UTM parameters there. Same with referrals that you don’t control (not everyone wants to put UTM parameters in their links).
  • This method doesn’t give you other important information about your customers: which device and browser they were using, their referrer,  where are they located etc. These are all important clues that can be valuable during the sales process and for analytics.

GA Connector solves all those issues and allows to track the whole user path, no matter which page they landed on, and at which point the submitted the form.

GA Connector remembers the initial channel, as long as the last channel, plus other useful information about this visitor.

Here is a section you will see for each of your Salesforce leads after implementing GA Connector:

GA Connector: Tracking website visitor information inside Google Analytics

GA Connector: Tracking website visitor information inside Salesforce

Sign up for GA Connector here.

Find out where your sales are really coming from

Enjoy your FREE 30-day trial, starting today

Connect my CRM and Google Analytics

2 Comments

  1. Hi
    We are à salesforce ngo with 10 donated seats through power of us program
    We would like to know if you have educational ngo pricing ?

    Br

  2. Awesome post. Thank your for sharing such a nice article.

Leave a Reply

Your email address will not be published.

*