SOLVED

What's bettter? To get value from utm parameter or cookie?

Go to solution
florenzoNIP
Level 2

What's bettter? To get value from utm parameter or cookie?

Hi all, 

Quick question here. I am currently in the process of adding mkto_UTM Campaign & mkto_UTM medium hidden fields to my forms, and up until now, I was using the URL parameter selection to pull from because we use URL parameters to track our email efforts and our paid search. 

 

If I continue to set it up this way, and someone navigates to my landing page from a page with UTM parameters on it, but then doesn't convert and goes somewhere else on the site and converts from a different form, will the original UTM parameters carry through from the original source URL? 

 

My initial thought is no, not unless I change my default values to pull from cookies. However, if I update it to pull from cookies, will the form then ignore the URL parameters from the direct page? 

 

If I have to pick one or the other, the URL tracking is definitely more important, but ideally, I'd like to capture both! 

 

Thanks in advance! 

Felicia

1 ACCEPTED SOLUTION

Accepted Solutions
Vladislav_Vagn1
Level 5

Re: What's bettter? To get value from utm parameter or cookie?

You are correct in stating that if somebody navigates away from the LP with UTMs, then you will lose those values if they fill out a form on the next page, if you are not using cookies. That is because the link that they clicked to get to the next page probably does not have UTMs.

 

I am not sure what you mean by "URL parameters from the direct page?"

 

Having said that, in my personal experience we almost always use the cookies route. It helps keep track of where the person came from as they navigate the site. If they come in from one set of UTMs one day and don't fill out the form, then return later with another set of UTMs from another tactic and fill out the form on that session, the cookie values should update to the latest UTMs used - the tactic that lead to the conversion.

View solution in original post

10 REPLIES 10
Vladislav_Vagn1
Level 5

Re: What's bettter? To get value from utm parameter or cookie?

You are correct in stating that if somebody navigates away from the LP with UTMs, then you will lose those values if they fill out a form on the next page, if you are not using cookies. That is because the link that they clicked to get to the next page probably does not have UTMs.

 

I am not sure what you mean by "URL parameters from the direct page?"

 

Having said that, in my personal experience we almost always use the cookies route. It helps keep track of where the person came from as they navigate the site. If they come in from one set of UTMs one day and don't fill out the form, then return later with another set of UTMs from another tactic and fill out the form on that session, the cookie values should update to the latest UTMs used - the tactic that lead to the conversion.

SanfordWhiteman
Level 10 - Community Moderator

Re: What's bettter? To get value from utm parameter or cookie?

It's not really a "what's better" situation. You always want the most authoritative and relevant attribution info.

 

If there are UTM params on the current URL, certainly you need those — but if there aren‘t, and you have stored UTMs in a cookie, you need those just as much.

 

You can use the advanced Auto-Fill code here to seek values in multiple places:

 

MktoForms2 :: Auto-Fill w/Cascade v1.1.2

 

The fieldFillRules array seeks the value in each channel from top to bottom, i.e. this would seek the utm_campaign in the current URL, then look for a cookie of the same name:

 

   var fieldFillRules = [      
      {
         name : "Last_Campaign__c",
         channel: "query",
         selector: "utm_campaign"
      },
      {
         name : "Last_Campaign__c",
         channel: "cookie",
         selector: "utm_campaign"
      }
  ];

 

 

 

florenzoNIP
Level 2

Re: What's bettter? To get value from utm parameter or cookie?

Thank you both very much! I am going to see if I can use the advanced rules so I can capture both the utm parameters on the link in the email and the cookie value. I would go with only cookies but I am afraid our site is too slow and will not write the cookie fast enough to attribute the value to the form fill if I only use cookies. 

SanfordWhiteman
Level 10 - Community Moderator

Re: What's bettter? To get value from utm parameter or cookie?


I would go with only cookies but I am afraid our site is too slow and will not write the cookie fast enough to attribute the value to the form fill if I only use cookies. 

It’s not possible for a site to be too slow to use cookies. Setting a cookie is synchronous, so all other code waits for the cookie to be set.

document.cookie = "mycookie=myvalue;path=/;domain=example.com";
// anything you run here is guaranteed to see the cookie in the cookie store
MannyP98
Level 1

Re: What's bettter? To get value from utm parameter or cookie?

Hi @SanfordWhiteman!

Found this post when researching how to approach setting UTM's more dynamically and thought this was really interesting.

I tried to test this out and am not able to get the hidden fields added to the form on submission.

Here is my test page with form: https://www.daysmart.com/vet/daysmart-vet-mops-testing-page/

I landed on a different page with UTM's on that URL, which sets them to the cookie values, then clicked a hyperlink on that page that took me to the test page above. After inspecting the page I can see that the UTM's still exist in the cookies.

The form has no hidden fields on it for these 2 parameters I'm testing on, also this code snippet is within the section,  MktoForms2.whenReady(function(form) { 

// New section for field fill rules
        var fieldFillRules = [
            { name: "gaconnector_Last_Click_Source__c", channel: "query", selector: "utm_source" },
            { name: "gaconnector_Last_Click_Source__c", channel: "cookie", selector: "ds__default_utm_source" },
            { name: "gaconnector_Last_Click_Medium__c", channel: "query", selector: "utm_medium" },
            { name: "gaconnector_Last_Click_Medium__c", channel: "cookie", selector: "ds__default_utm_medium" }
        ];

        var liveChannels = {
            cookie: FormsPlus.util.Cookies.get(),
            query: FormsPlus.util.URI.URI().search(true),
            referrerQuery: FormsPlus.util.URI.URI(document.referrer).search(true),
            localStorage: localStorage,
            sessionStorage: sessionStorage
        };
      
        var mktoFields = fieldFillRules.reduce(function(acc, fieldDescriptor) { 
            if (!acc[fieldDescriptor.name]) {
                acc[fieldDescriptor.name] = fieldDescriptor.channel === "constant"
                    ? fieldDescriptor.selector
                    : liveChannels[fieldDescriptor.channel][fieldDescriptor.selector];
            }
            return acc;
        }, {});

        form.addHiddenFields(mktoFields);

MannyP98_1-1731608182285.png

 

 

Jo_Pitts1
Level 10 - Community Advisor

Re: What's bettter? To get value from utm parameter or cookie?

@MannyP98 ,

you've said "The form has no hidden fields on it for these 2 parameters I'm testing on"

did you mean that, or did you mean the 'no' to be two?

Cheers

Jo

 

MannyP98
Level 1

Re: What's bettter? To get value from utm parameter or cookie?

@Jo_Pitts1 
There are several other hidden fields on the form but none for the two values that I'm trying to pick up with the script (Source & Medium).

Sorry if that was confusing! 

SanfordWhiteman
Level 10 - Community Moderator

Re: What's bettter? To get value from utm parameter or cookie?

You forgot to include the FormsPlus Core Library. (Upload to Design Studio and load from there.)

 

Be sure to check your browser console for error messages. This one is pretty clear.

SanfordWhiteman_0-1731621794798.png

 

MannyP98
Level 1

Re: What's bettter? To get value from utm parameter or cookie?

@SanfordWhiteman 
Ahhh of course, totally forgot to check the console log - thank you as always!