Re: Passing UTM values to iframe embedded forms

Jon_Bourne
Level 2

Re: Passing UTM values to iframe embedded forms

Sanford, you are correct in that it is insufficient to detect every possible TLD/public domain and, consequently, private domain. Regex only gets you so far. However, given that, to date, our team has controlled the installation of the script, I have not been too terribly concerned about this known issue; we usually will manually set the cookie domain when and where needed as opposed to relying on the auto-detect functionality.

That said, I appreciate the excellent research and write-ups you posted. Nice work! Since you have on your blog already granted permission for its use with appropriate attribution and copyright, I will probably include findPrivateSuffix() in the next iteration of this script.

Anonymous
Not applicable

Re: Passing UTM values to iframe embedded forms

Wow, this is great stuff Jon Bourne​. Regarding the domain being auto-detected, do you know if this will work on our .cn (Chinese) website? We have a .com and .cn version of the site and, due to the way things are set up, it would be easier to use one script. However, if you recommend manually setting the cookie domain anyway then I will do this and use different versions for each domain.

Jon_Bourne
Level 2

Re: Passing UTM values to iframe embedded forms

Hi Ben. Yes, you'll need to set the cookie domain manually at the top and host two separate instances of the script—one on each domain. As a security feature, Javascript can only read cookies for the domain on which it is hosted; if you have two (or more) entirely different domains, you will need to host an instance of the UTM tracking script on each domain.

Oh, and if you're targeting China specifically, make sure you're not loading scripts or other page assets from any Google servers. They're blocked (along with many other providers). We've run into this before and had to move these assets to clients' web servers or Design Studio.

Anonymous
Not applicable

Re: Passing UTM values to iframe embedded forms

Thanks again for the reply. I have another question on this - do you suggest using the script across the whole site? So, if someone arrives at the homepage via UTM-tagged link, that's captured in the cookie and written to the lead when they fill out a form.

Or do you suggest just adding it to pages with a form, so only visits to those pages are tracked?

SanfordWhiteman
Level 10 - Community Moderator

Re: Passing UTM values to iframe embedded forms

Ben, I think I can safely speak for Jon here: using cookies to persist UTM info means you want to keep a trail back to the first touch (possibly also including the conversion touch, if present, and other touches in-between). So while the script's code may intelligently react to navigation over time -- excluding paths and terms, expiring cookies after a period of time, keeping a rolling window of touches -- you almost always want the <script> itself to load on every page.

Also, it wouldn't make sense to use cookies if your sole goal were to pass URL data from a main document to an IFRAMEd form on the same page: cookies won't work across private domain suffixes, and the cookie will be set even if the person doesn't convert (i.e. it will be present on future visits to any page matching the cookie domain).  It's meant to be part of a larger scope.

Anonymous
Not applicable

Re: Passing UTM values to iframe embedded forms

Thanks, good to know. I think in our case using the script everywhere will be best, as we do want to try and build a picture of all touches, not just the immediate touch prior to a conversion. This is part of a bigger project to do better attribution.

Anonymous
Not applicable

Re: Passing UTM values to iframe embedded forms

Jon Bourne​...firstly, thanks again for the script - I've implemented it and it's working well.

There is one specific issue though: let's say a lead comes to the site via a link with utm_campaign, utm_source, utm_medium and utm_term parameters. This info is stored in the relevant fields when the lead fills out a form. They then come back to the site later via a different link with only utm_source and utm_medium present. In this instance, the utm_source and utm_medium fields are overwritten, but utm_campaign and utm_term data remains from their previous visit, so we end up with a mixture of mismatched data. Does that make sense?

Do you know of a way to overcome this? The ideal scenario would be something in the form/script that says 'when at least one UTM value is present, overwrite new UTM values and clear the fields where a new UTM value doesn't exist'.

It's probably a somewhat narrow use case, but I can see it applying to leads where UTM Term and UTM Content data is captured (on leads from paid search, for example), as many links won't have this level of detail and may just have campaign, source and medium.

SanfordWhiteman
Level 10 - Community Moderator

Re: Passing UTM values to iframe embedded forms

Sure, go ahead and use it. Your regex only covers a few possibilities, so "usually don't need" seemed off. Note the regex will fail on hundreds of .com and .net domains. It's not just about other TLDs.

Anonymous
Not applicable

Re: Passing UTM values to iframe embedded forms

Josh Hill​, Sanford Whiteman​, Jon Bourne​ - many thanks for your helpful suggestions. I would prefer to embed the form directly on the page but it would require a lot of work editing existing pages.So will look into implementing your suggestion, Sandford.