28 Replies Latest reply on Jul 3, 2018 7:02 AM by Juli James

    UTM parameters not populating into utm fields

    Laura Mighdoll

      We're having a consistent issue where a record will enter our database from a URL that has UTM parameters within the link. However, those UTM parameters do not populate from the referrer into the UTM fields (utm_medium, utm_ source, etc.). I've scanned the community and have not seen anyone discuss the same issue (< if you have, please point me in that direction).

       

      For example, a lead would enter our database from this referrer: https://tripactions.com/?utm_source=google&utm_medium=sem&device=t&matchtype=b&keyword=business%20travel&campaignid=7497…

       

      but the fields are empty:

      Screen Shot 2018-06-11 at 10.14.06 AM.png

       

      This happens for multiple sources, both within Marketo hosted pages as well as external ads: paid search, paid social, our unsubscribe landing page, webinar landing pages, etc.

       

      An outside resource brought the idea that the lead could have deleted the part of the URL that has UTM parameters within it in an attempt to untrack themselves, however this is not the case as the original referrer and the referrer url have the full link with utm parameters in it.

       

      To try to fix this originally, we added code on our forms a while back that could capture UTM parameters for about a day in case something was dropping them on the backend. This would ensure the utm parameters would persist from page to page as a record flipped throughout various web pages. To do so we added cookied fields ft_utm_medium, ft_utm_source, etc. that would hold the value then populate the real utm fields.

       

      In addition to this fix, I have a workflow running within our Global Lead Source program that looks for records that have utm parameters within the original referrer and reads the UTMs to correctly attribute the record. But this catch does not populate the utm fields.

       

      We're eager to find the source of this issue and a fix. Has anyone seen this before? Does anyone think a reasonable fix is to create a smart campaign that finds anyone with utm parameters in the original referrer and has a flow step that populates the utm fields?

       

      Thanks for the help!

        • Re: UTM parameters not populating into utm fields
          Sanford Whiteman

          Laura, I think you've misunderstood what does and doesn't require manual config in Marketo.

           

          Moving query parameters into lead fields always requires you to add the fields as hidden at the form level. It's not automatic.

          • Re: UTM parameters not populating into utm fields
            Juli James

            Hi Laura and Sanford!

             

            I'm having a similar issue with an instance I'm working in.  Sometimes the UTM parameters are captured, and sometimes they aren't.  They always capture when its a new lead, but if it's someone who has been on various pages and downloaded various things with different URL's and UTM parameters then it doesn't always capture the information. 

             

            I'm going to be doing some testing tomorrow, however, I was wondering if the issue could be in the cookies that are being places on machines, as when I clear all mine or use the private browsing windows, the UTM parameters always pull into the fields in Marketo without any issues.

             

            Thanks

            Julz

            1 of 1 people found this helpful
              • Re: UTM parameters not populating into utm fields
                Sanford Whiteman

                Well, it depends on what (if any) code you're using to persist UTM parameters from one page to another, whether it's running on all pages (it should be), whether its internal logic is sound, and whether it's aware of script load + execution order (so it's always finished when the cookies are needed).

                 

                If you're not using any special code, then UTM params will never fill from cookies, ever, so you must have something.

                 

                If you're using code that stores empty values in cookies instead of overwriting them (which can sometimes be strategically sound) then params may in fact be getting filled, they'll just be getting filled with a stored empty string.

                 

                But any number of things can go wrong when code isn't properly tested or implemented. I'd have to see what you're using to be able to tell.

                • Re: UTM parameters not populating into utm fields
                  Laura Mighdoll

                  Hi Juli,

                   

                  We set up additional UTM parameters using the "fm_utm_medium", etc. We then built code that then holds the cookied value within these fields for a longer period of time, these fields then write to our original utm fields (utm_medium, etc.). This helps solve the issue of utm values dropping off as they move from page to page.

                   

                  There are still situations where the person could drop of the utm values off the URL.

                   

                  Here's the code we implemented:

                   

                  <script>

                  /*

                  * BEGIN CAPTURE UTM PARAMETERS FROM FIRST TOUCH AND LAST TOUCH

                  * Copyright (c) 2017, Yanir Calisar, Tel Aviv, Israel (ycalisar at gmail.com)

                  *

                  * Permission is hereby granted, free of charge, to any person obtaining a copy of this code and associated documentation files, to deal in the code without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the code.

                  * The user assumes responsibility for determining appropriate use of the code, for consequences of its use, and for checking functionality against other reliable sources.

                  * We suggest citation in publications as with any code developement work. No warrantee is given.

                  * Please help improve the code by sending suggestions or new code back.

                  */

                   

                  (function() {

                   

                      var STORE_COOKIES = true;

                      var STORE_LOCAL_STORAGE = true;

                   

                      function topDomain() {

                          var i, h, top_level_cookie = 'top_level_domain=cookie', hostname = document.location.hostname

                                  .split('.');

                          for (i = hostname.length - 1; i >= 0; i--) {

                              h = hostname.slice(i).join('.');

                              document.cookie = top_level_cookie + ';domain=.' + h + ';';

                              if (document.cookie.indexOf(top_level_cookie) > -1) {

                                  document.cookie = top_level_cookie.split('=')[0] + '=;domain=.'

                                          + h + ';expires=Thu, 01 Jan 1970 00:00:01 GMT;';

                                  return h;

                              }

                          }

                      }

                   

                      var utmCookie = {

                          cookieNamePrefix : "__lt_",

                          cookieCumulativePrefix: "__cu_",

                          cookieNameFirstTouchPrefix : "__ft_",

                   

                          utmParams : [ "utm_source", "utm_medium", "utm_campaign", "utm_term",

                                  "utm_content" ],

                   

                          cookieExpiryDays : 365,

                   

                          // From http://www.quirksmode.org/js/cookies.html

                          createCookie : function(name, value, days) {

                   

                              if(STORE_COOKIES) {

                                  if (days) {

                                      var date = new Date();

                                      date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));

                                      var expires = "; expires=" + date.toGMTString();

                                  } else

                                      var expires = "";

                                  document.cookie = this.cookieNamePrefix + name + "=" + value

                                      + expires + ";domain=." + topDomain() + ";  path=/";

                              }

                              if(STORE_LOCAL_STORAGE) this.createLS(name, value);

                          },

                   

                          createLS: function(name, value){

                              localStorage[this.cookieNamePrefix+ name] = value;

                          },

                   

                          readCookie : function(name) {

                   

                              if(STORE_COOKIES) {

                                  var nameEQ = this.cookieNamePrefix + name + "=";

                                  var ca = document.cookie.split(';');

                                  for (var i = 0; i < ca.length; i++) {

                                      var c = ca[i];

                                      while (c.charAt(0) == ' ')

                                          c = c.substring(1, c.length);

                                      if (c.indexOf(nameEQ) == 0)

                                          return c.substring(nameEQ.length, c.length);

                                  }

                                  if(STORE_LOCAL_STORAGE) this.readLS(name);

                                  else return null;

                              }

                              if(STORE_LOCAL_STORAGE) this.readLS(name);

                          },

                   

                          readLS: function(name){

                              var val = localStorage[this.cookieNamePrefix + name];

                              if(val == undefined) return null;

                              else return val;

                          },

                   

                          checkIfFirstTouch : function() {

                              if(STORE_LOCAL_STORAGE) {

                                  var nameEQ = this.cookieNameFirstTouchPrefix + "utm_source=";

                                  var ca = document.cookie.split(';');

                                  for (var i = 0; i < ca.length; i++) {

                                      var c = ca[i];

                                      while (c.charAt(0) == ' ')

                                          c = c.substring(1, c.length);

                                      if (c.indexOf(nameEQ) == 0)

                                          return c.substring(nameEQ.length, c.length);

                                  }

                                  if(STORE_LOCAL_STORAGE) this.readLS(this.cookieNameFirstTouchPrefix + "utm_source");

                                  else return null;

                              }

                              if(STORE_LOCAL_STORAGE) this.readLS(this.cookieNameFirstTouchPrefix + "utm_source");

                          },

                   

                          eraseCookie : function(name) {

                              if(STORE_COOKIES) this.createCookie(name, "", -1);

                              if(STORE_LOCAL_STORAGE) delete localStorage[name];

                          },

                   

                          getParameterByName : function(name) {

                              name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");

                              var regexS = "[\\?&]" + name + "=([^&#]*)";

                              var regex = new RegExp(regexS);

                              var results = regex.exec(window.location.search);

                              if (results == null) {

                                  return "";

                              } else {

                                  return decodeURIComponent(results[1].replace(/\+/g, " "));

                              }

                          },

                   

                          utmPresentInUrl : function() {

                              var present = false;

                              for (var i = 0; i < this.utmParams.length; i++) {

                                  var param = this.utmParams[i];

                                  var value = this.getParameterByName(param);

                                  if (value != "" && value != undefined) {

                                      present = true;

                                  }

                              }

                              return present;

                          },

                   

                          writeUtmCookieFromParams : function() {

                              for (var i = 0; i < this.utmParams.length; i++) {

                                  var param = this.utmParams[i];

                                  var value = this.getParameterByName(param);

                                  if(STORE_COOKIES) this.createCookie(param, value, this.cookieExpiryDays);

                                  if(STORE_LOCAL_STORAGE) localStorage[param] = value;

                              }

                          },

                   

                          writeCookieOnce : function(name, value) {

                   

                              if (STORE_COOKIES && !this.readCookie(name)) {

                                  this.createCookie(name, value, this.cookieExpiryDays);

                              }

                              if(STORE_LOCAL_STORAGE && this.readLS(name) == null){

                                  this.createLS(name,value);

                              }

                          },

                   

                          writeReferrerOnce : function() {

                              var value = document.referrer;

                              if (value === "" || value === undefined) {

                                  this.writeCookieOnce("referrer", "direct");

                              } else {

                                  this.writeCookieOnce("referrer", value);

                              }

                          },

                   

                          referrer : function() {

                              return this.readCookie("referrer");

                          }

                      };

                   

                      if (!utmCookie.checkIfFirstTouch()) {

                          utmCookie.cookieNamePrefix = utmCookie.cookieNameFirstTouchPrefix;

                          utmCookie.writeReferrerOnce();

                   

                          if (utmCookie.utmPresentInUrl()) {

                              utmCookie.writeUtmCookieFromParams();

                          }

                          utmCookie.cookieNamePrefix = "__lt_";

                      }

                   

                      utmCookie.writeReferrerOnce();

                   

                      if (utmCookie.utmPresentInUrl()) {

                          utmCookie.writeUtmCookieFromParams();

                         

                      }

                  })();       

                  /* END CAPTURE UTM PARAMETERS FROM FIRST TOUCH AND LAST TOUCH */

                  </script>

                  1 of 1 people found this helpful
                  • Re: UTM parameters not populating into utm fields
                    Zach Rogers

                    Hi Juli,

                    You probably already know this since you're the best (loved your talk at Summit this year!) but we had this same problem and realized we had to ensure to disable autoform fill on our hidden UTM fields.

                  • Re: UTM parameters not populating into utm fields
                    Sant Singh Rathaur

                    Hi Laura,

                     

                    We have been using 'URL Parameter' instead of Cookie value and it's working fine for us as of now.

                    • Re: UTM parameters not populating into utm fields
                      Conor Fitzpatrick

                      Sanford, I am running into issues similar to Laura and am testing out your approach (that Dan referenced above). I'm working with native Marketo landing pages and am wondering how I can place the forwarding script in between the forms2.min.js and MktoForms2.loadForm scripts.

                      • Re: UTM parameters not populating into utm fields
                        Inga Romanoff

                        I am a little late to the party here... we developed a solution (with someone's help on this thread!) which we used to distribute open source. It's now a one-time affordable install fee and includes a workshop on taxonomy / tracking utm parameters.

                         

                        Yes-without a special code, you are lucky to capture Last Touch, but only and only if the lead landing on the web page fills out the form right away. If they flipped through a couple of pages and came back to fill out the form, they will inevitably lose all utm parameters. We utilize javascript to capture this information and then, it's automatically disseminated into marketo fields. (But our solution will record both First Touch and Last Touch; First Touch is especially useful to those in tradition B2B models as the lead lifecycle is longer).

                         

                        Check the solution out on our site or on Launchpoint or let me know if you have any questions!

                        http://romanoff.live/solutions

                        tracking marketing attribution - ConversionPath » Marketo LaunchPoint®

                        1 of 1 people found this helpful
                        • Re: UTM parameters not populating into utm fields
                          Keenan Murphy

                          Also late to the party, but for about a year now, I have been using this code from this Digital Pi article with zero problems.

                           

                          It creates a cookie that stores a visitor's UTM parameters (you can also change the parameters to be any custom parameters - just make sure that what you put in the urls matches what the script is looking for), and those values persist for 365 days or until new values overwrite them. This is important for people who click a link to a landing page, but subsequently navigate around to other pages or maybe come back during separate session.

                           

                          One word of caution there: if you send someone a link with an incomplete set of parameters (say you just input medium, source, campaign, but left term and content blank) the new values will overwrite, but the old values will stay the same, meaning when that visitor submits a form you'll have inaccurate information on the content + term.

                           

                          The instructions are pretty clear around setting up your form and implementing the code, but just make sure you're loading the script in the body below the form and swapping out the domain (if you want to use on subdomains and main site, you'll need to use ".yoursite.com") or custom parameter names that you want to use.

                           

                          Also, its easy to overlook the link to the actual code in that article, which is here.

                            • Re: UTM parameters not populating into utm fields
                              Sanford Whiteman

                              One word of caution there: if you send someone a link with an incomplete set of parameters (say you just input medium, source, campaign, but left term and content blank) the new values will overwrite, but the old values will stay the same, meaning when that visitor submits a form you'll have inaccurate information on the content + term.

                              Better implementation NULLs those fields.