Capturing Lead Source Using UTM Fields | Community
Skip to main content
January 27, 2016
Question

Capturing Lead Source Using UTM Fields

  • January 27, 2016
  • 3 replies
  • 8760 views

I have been doing some research on this topic and wanted to validate that I am understanding correctly what needs to be done to capture lead source from a URL.

Do I need to create a field labeled: utm source?

Then append URL's with ?utm_source=website to capture the word "website" into the custom UTM Source field?

For example, my team posted a video to our website that is tracked by a munchkin tracking code.  I originally had our team append the URL with ?source=website but the information wasn't being transferred to the lead.  In doing some research it appears this isn't possible without putting a form on the page with a hidden field to capture this information.  So I am thinking the above may be the correct work around?

I appreciate any input on this topic.

Thank you!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

Grégoire_Miche2
Level 10
January 27, 2016

Hi Christine

You can capture the value "website" in any Marketo field. You can create a field "utm source" or use the default field "lead source", if you want.

To capture the data, you need to add this field to your forms, as hidden a field, then set the field value to be a URL parameter, and set the url parameter name to utm_source.

-Greg

January 28, 2016

Thank you, Gregoire for your response.

What if the page I am trying to capture the source from does not contain a Marketo form?  I understand the hidden form field capture, I'm trying to capture certain source codes from the URL.

Thank you,

Christine

Grégoire_Miche2
Level 10
January 28, 2016

Hi Christine,

Do you mean the entry page on the site does not contain any form or the page does contain a form that is not a Marketo form ?

  • in the first case, this is a little complex. You need to have the utm values stored in session cookies so that Marketo can fill out the hidden fields from these cookies. It wil usually take some (not overly complex) java script
  • in the second, Marketo cannot do anything about it You'll have to see with the Non Marketo form developper to capture the utm values.

-Greg

SanfordWhiteman
Level 10
February 4, 2016
I originally had our team append the URL with ?source=website...

Christine, there's a cool trick in this area that (I think) almost nobody knows about.

If you want to transfer one data point from the URL to a lead field, like lead source in your case, and you don't know the possible data values (or don't want to manage them), add that data point as the s -- just the letter "s" -- query parameter.  (Like how you were trying to use the source param.)

    landing.example.com?param1=whatever&s=linkedin

On the page, fire a simple Munchkin event. In the url include the name of the lead field you want to update to the value of s. Here, Munchkin is signaling that you're setting the lead field utm_source to the current value of s ("linkedin").

     Munchkin.munchkinFunction('visitWebPage', { url: '/dataValueTransfer/utm_source'  });

Your Smart List watches for any visit to /dataValueTransfer/...

... and your Flow sets data values accordingly:

The advantage of this quick-and-dirty method should be easy to see: the value you're putting on the lead is available as a special trigger token {{trigger.Search Query}}!  (The s query param is the old-school way that search engines would tell you the search terms the user entered, back when they didn't care if you knew.)  Since you have the token, you don't need to know the possible values, so it's a lot like a form post with a single field.  It could contain any value at all (s=blee, s=blah, s=somethinganoutsideagencydidnttellyouaboutbutthatsokay) and that value will get popped into the corresponding value on the lead.

Anyway, food for someone's thought, I hope... not a fit for more complex situations but I thought I'd share it!

Note: You can actually adapt this same technique for multiple values per page view, though in uplevel browsers only.  Since that excludes IE 8-9 I won't include the method here to make sure everything is compatible.

Nicholas_Manojl
Level 8
February 5, 2016

Hi Sanford - great post.

Why wouldn't you just do a "Change data value" on Lead Source to {{trigger.search query}} when a fills-out-form is completed?

I think I'm having trouble understanding what the query paramater ?s is all about.

Edit: because the Trigger.Search Query only works on a 'Visits web page' trigger right?

SanfordWhiteman
Level 10
February 5, 2016

Edit: because the Trigger.Search Query only works on a 'Visits web page' trigger right?

Right! Specifically, in this case, the manual call to Visit Web Page sets the referrer to the current document (as opposed to the previously navigated document), so the s of the current doc becomes the {{trigger.search query}}.

And of course the reason this is cool is that you don't need to wait for a form fillout or other moment to save the information to the lead, or more properly with Munchkin 2.0, "prepare the information to be saved to the lead at the moment it is promoted from anonymous."

February 5, 2016

I recently had to solve this exact issue at Yesware and wrote an open source library which will do it for you.

Firstly, it's important to understand how UTM parameters work when using Google Analytics. UTM parameters apply to a single visit (session) only. If a user clicks on a link which is tagged, that session will be associated with the UTM parameters. E.g. ?utm_source=adroll&utm_medium=display will place that session into the Display channel within Google Analytics. If the user fills out a form during that session, you'll want to define that as a goal with in GA and you'll be able to see the conversion rate of that channel. If the user doesn't convert and then comes back to your site, you won't want to reuse any previous UTM parameters as they won't be correct.

The previous version of the GA tracking code would save these for you in a cookie named _utmz, but the current version no longer does this.

When a user visits your site with UTM parameters in the URL, you'll want to save these into a cookie which expires at the same time as the GA session, which by default is after 30 minutes of inactivity. If at any time in the session new UTM parameters on the URL are detected, then the previous values should be overwritten as GA has started a new session at this point.

When a user fills out a form (becomes known), you'll want to fire a GA event which is setup as a Goal in GA and also pass the saved cookie values to Marketo.

I've created a library to do the first piece: https://github.com/Yesware/last-campaign

On every page of your site, you would just include the script and call "lastCampaign()", this will save the UTM parameters into a session cookie.

Then on your form you can add hidden fields with populated with the value of the cookies: utm_campaign, utm_medium, utm_source, utm_term, and utm_content. Alternatively, you can use some JavaScript on your landing pages which will automatically add the hidden fields and populate them. Here is an example that will do that for you: https://gist.github.com/lukebussey/c1aeb4113e90c519d522

I hope this is helpful.

SanfordWhiteman
Level 10
February 5, 2016

Here is an example that will do that for you: gist.github.com/lukebussey/c1aeb4113e90c519d522

Cool script! But it has a race condition that a 200ms timeout will not fix.  Use the hitCallback as noted here: https://nation.marketo.com/thread/5577#118658. This kind of thing is frequent source of lost logs.

February 8, 2016

Fantastic. Thanks!