banner



Debug Auxdata Key Utm_campaign Contains Null Value Please Check

Updated: October 1st, 2020.

I have completely redone this solution to support more cases and require less configuration. However, in some situations, the older version of this solution is recommended. If the destination URL contains a hashmark (#), you should try using the older version.

====

Imagine this. You're running a promo campaign that brings traffic to a certain landing page (e.g. landingpage.com). After the visitor clicks the main Call-to-action button (e.g. GET YOUR DISCOUNT), he/she is redirected to another page (2ndpage.com) which asks a visitor to do the final action, install the app, fill in the form, sign up, etc.

When the conversion is completed, a Google Analytics event is fired. Unfortunately, when you look at your GA reports, what you'll see is that all conversions are attributed to thelandingpage.com. Technically, this is correct because all visitors landed on the2ndpage.com fromlandingpage.com, but you'd like to see the original source which brought the visitor, wouldn't you?

Normally, you'd need to implement cross-domain tracking here but in some cases that is not possible (I'll explain them a bit later).

In this blog post, I'll show you how to transfer UTM parameters (or basically any URL parameters) from the initial pagelandingpage.comto the subsequent one (2ndpage.com) if the cross-domain tracking cannot be implemented.

The problem explained

Say, that you're promoting a product that is available in the App Store (for example, Shopify App Store). We'll call it Lorem Appsum. Its App Store page isn't sufficient to list all the benefits, cool features, etc. So you decided to create a separate landing page that you'll drive traffic to. You have also marked all inbound links (stored on other websites/forums/etc.) that lead visitors to that landing page with UTM parameters.

That new landing page contains key selling points, descriptions of features, video, and a bigGET APP NOWbutton (Call-to-action, a.k.a. CTA). Perfect. The visitor lands on the initial page, he clicks that CTA button, lands on the App Store page and installs the app. Heres' the scheme of the entire visitor journey:

Visitor journey

Notice that UTM parameters are lost after the visitor clicks an appstore.com link on loremappsum.com page.

The problem is that Google Analytics will attribute this conversion to loremappsum.com, although it would be more beneficial to see the values of the initial UTMs.

Why not implement GA cross-domain tracking?

In the case of app stores, usually, creators/developers are not allowed to edit Google Analytics tracking code, therefore cross-domain tracking cannot be configured properly.

This is what we faced with Omnisend (when I was working there) at Shopify Appstore. We were allowed to set Google Analytics Tracking ID, and that's it. Unfortunately, in order to make cross-domain tracking work, we also needed to enable allowLinker option on the receiving domain (app store) but that was not possible.

So we had to improvise and this blog post is the solution to the problem.

The Solution – Overview

Update: This is version 2 of the solution. With it:

  • you will be able to transfer any query parameters (not only UTMs)
  • you will not need to create URL variables
  • you can decorate links of multiple domains
  • and query parameters that you want to transfer are optional (this means that if utm_campaign is not present in the URL, the solution will still work).

====

One of the solutions is to transfer UTM parameters fromloremappsum.com and automatically add them to all links which redirect users toappstore.com/loremappsum. We'll do this with Google Tag Manager and a custom script.

Important: if you notice that the script is not working in some situation, please let me know and I'll see what I can do to fix it.

<script> (function() {   var domainsToDecorate = [           'domain1.com', //add or remove domains (without https or trailing slash)           'domain2.net'       ],       queryParams = [           'utm_medium', //add or remove query parameters you want to transfer           'utm_source',           'utm_campaign',           'something_else'       ]   // do not edit anything below this line   var links = document.querySelectorAll('a');   // check if links contain domain from the domainsToDecorate array and then decorates   for (var linkIndex = 0; linkIndex < links.length; linkIndex++) {       for (var domainIndex = 0; domainIndex < domainsToDecorate.length; domainIndex++) {            if (links[linkIndex].href.indexOf(domainsToDecorate[domainIndex]) > -1 && links[linkIndex].href.indexOf("#") === -1) {               links[linkIndex].href = decorateUrl(links[linkIndex].href);           }       }   } // decorates the URL with query params   function decorateUrl(urlToDecorate) {       urlToDecorate = (urlToDecorate.indexOf('?') === -1) ? urlToDecorate + '?' : urlToDecorate + '&';       var collectedQueryParams = [];       for (var queryIndex = 0; queryIndex < queryParams.length; queryIndex++) {           if (getQueryParam(queryParams[queryIndex])) {               collectedQueryParams.push(queryParams[queryIndex] + '=' + getQueryParam(queryParams[queryIndex]))           }       }       return urlToDecorate + collectedQueryParams.join('&');   }    // borrowed from https://stackoverflow.com/questions/831030/   // a function that retrieves the value of a query parameter   function getQueryParam(name) {       if (name = (new RegExp('[?&]' + encodeURIComponent(name) + '=([^&]*)')).exec(window.location.search))           return decodeURIComponent(name[1]);   }  })(); </script>

Once the visitor lands on loremappsum.com AND the Page URL contains utm_medium, utm_source, or any other URL parameter (that you're interested in), the tag will fire. It will scan the entire page and look for links that contain the domain(s) of the final landing page, in this case, appstore.com.

If the script finds the link, it will:

  1. Fetch URL parameters (e.g. UTMs) from the browser's address bar.
  2. And will add those parameters to that spotted link (which contains "appstore.com").

So instead of appstore.com/loremappsum,all links onloremappsum.com will be automatically modified toappstore.com/loremapsum?utm_medium=referral&utm_source=promo &utm_campaign=blackfriday2017.Here's the updated visitor flow:

Updated Visitor Journey

This solution does not cover 100% of cases

There are situations where this solution will not work properly:

  • If the URLs that you wish to decorate contain #, try using the older version of the solution
  • If the URLs that you wish to decorate already contain query (a.k.a. URL) parameters from the Custom HTML tag, they will not be replaced. The script will append them to the URL (therefore, you will end up with duplicate parameters).

Notice more situations where the script does not work as expected? Let me know in the comments and I'll see what I can do.

The Solution – Implementation in GTM

In Google Tag Manager, create a custom HTML tag and paste the JavaScript code that I provided in the previous chapter.

Now, we need to do some configuration.

Edit the list of domains

On line 3, you'll see this domainsToDecorate array:

          var domainsToDecorate = [           'domain1.com', //add or remove domains (without https or trailing slash)           'domain2.net'       ],

Here you must enter the domain(s) of the final landing page(s). If a visitor lands on the intermediary landing page, the script will be looking for links that contain the domain(s) from thedomainsToDecorate array.

In other words, if the journey issome website > loremappsum.com > appstore.com, then you must enter "appstore.com" in thedomainsToDecoratearray.

If you want to decorate URLs of just one domain, you can keep just one domain. If you want to add 4 domains, you can do that as well. Just make sure you don't leave any typos, missing commas or apostrophes.

If you want to be more specific and decorate only some links, you can be even more specific. Instead of the appstore.com, you can enter appstore.com/your-app.

Here is an example with just one domain (obviously, you should replace that domain):

          var domainsToDecorate = [           'appstore.com'       ],

Add URL parameters you want to transfer

Next, you must edit the list of URL parameters you want to take from the page URL and transfer them to particular outbound (outgoing) links.

If for example, Page URL (where a visitor currently is) ishttps://www.loremappsum.com/?utm_medium….., then those parameters (e.g. utm_medium) will be added to all the URLs of theappstore.com, e.g. https://appstore.com/loremappsum/?utm_medium…

queryParams = [           'utm_medium', //add or remove query parameters you want to transfer           'utm_source',           'utm_campaign',           'something_else'       ]

What's cool with the recent update of this solution is that:

  • You don't have to create GTM variables for each parameter
  • You can transfer any URL parameter (a.k.a. query parameter), not only UTMs
  • The parameters you entered in thequeryParams array are all optional. If Page URL does not contain, say, utm_campaign, the script will still work just fine
  • UTMs can contain a "+" sign as well. It will be transferred just fine and will not be encoded to%2B.

Here's an example of what the setup could be:

queryParams = [           'utm_medium',           'utm_source',           'utm_campaign',           'ref'       ]

Save the tag. Now, it's time for a trigger.

Trigger

You don't want to fire this Custom HTML tag on every page. Instead, you should activate it only when the URL contains at least one of those query parameters that you want to transfer. Let's continue our example where I entered these query parameters in the Custom HTML tag:

queryParams = [           'utm_medium',           'utm_source',           'utm_campaign',           'ref'       ]

So, if any of these parameters are in the URL, the Custom HTML tag should fire. Every parameter in the URL should also contain an "equals" sign (=), therefore, our trigger's condition should be like this:

  • Trigger type: DOM ready
  • Fire on some DOM Ready Events
  • Page URLmatches RegEx (ignore case) utm_medium=|utm_source=|utm_campaign=|ref=

What I did here is that I have added "=" after every parameter and then separated them with a pipe ( | ), which in Regular Expressions means "OR". Of course, we could write a more optimized expression such as:

utm_(medium|source|campaign)=|ref=

or something even slimmer but even the first example will work just fine. If you don't feel confident with regex, just enter all the query parameters you are interested in, add "=" after each one of them, and separate them with a |.

Save this trigger and assign it to the Custom HTML tag.

Let's Test

Save all changes, enable Preview and Debug mode. Now head over to the page you're working on. There are two situations we need to test:

  1. Make sure that is at least one of the query parameters (that you want to transfer) in the Page URL. In my case, the page URL iswww.loremappsum.com?utm_medium=referral&utm_source=promo &utm_campaign=blackfriday2017
  2. Click the link which contains the domain name you have defined in that custom script I've shared in this blog post. In my case, it'swww.appstore.com/loremappsum
  3. After I'm redirected, the Page URL (appstore.com/loremappsum) should also contain those 3 UTM parameters. The final result in the browser's address bar should be www.appstore.com/loremappsum?utm_medium=referral&utm_source=promo &utm_campaign=blackfriday2017
    Appstore URL in browser address bar

Also, do not forget to test the opposite situation when there are no UTMs (or other parameters) in the address bar. In that case, nothing should be appended to appstore.com links.

Oh, there's also a third case to test, check at least a couple of other external links (unrelated to appstore.com), they should never contain UTM parameters.

Transfer UTM Parameters: Final words

In this blog post, I've explained how to transfer UTM parameters (or any other URL parameters) from one page to another. This is really useful when you have an intermediate landing page that you're attracting visitors to, and then they have to proceed to the final page which is stored in another domain.

This is a plan B if you cannot implement Cross-domain tracking for some reason.

By default, you'd lose all attribution data and Google Analytics will display your intermediate landing page as the main referral.

With the script I've shared, you'll be able to reuse UTM parameters of the initial landing page and decorate certain links with them.

However, keep in mind that obviously, navigation between the intermediary page and the final landing will start a new session (and the same person will still be treated as two different people in your GA reports).

The situation I've described is not a very common issue, but it occurs from time to time. Actually, one of my readers has recently asked a question related to this very same topic.

Debug Auxdata Key Utm_campaign Contains Null Value Please Check

Source: https://www.analyticsmania.com/post/transfer-utm-parameters-google-tag-manager/

Posted by: harrisonriseed.blogspot.com

Related Posts

0 Response to "Debug Auxdata Key Utm_campaign Contains Null Value Please Check"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel