Cardinal Path’s response to COVID-19 Cardinal Path is sharing all we know to help marketers during COVID-19.  Learn more.

This is a 3 part series on cross domain tracking with Google Analytics in non-standard situations:

  1. Part 1
  2. Part 2
  3. Part 3

In this final of our three part series, we’re going to look at adding the Google Analytics query string parameters used to accomplish cross domain tracking to other variables we may be passing.

If we want to append additional query string variables to the end of our destination URL string we might try something along the lines of the following:

<code>
function redirectFunction()
{
window.location.replace(GoogleAnalyticsCookieAppend('http://www.xxx.yyy/
RedirectTarget.html?mookie=pookie'));
}
</code>

If we do this, it’s possible that we might also notice that our cookie passing solution no longer works.

Uh-oh.

If you find yourself in this situation, it might be because of this:

<code>
http://www.xxx.yyy/RedirectTarget.html?mookie=pookie#__utma=
1.283748562613819500.1212185562.1212185562.1212189988.2&__utmb=
-&__utmc=1&__utmx=-&__utmz=1.1212185562.1.1.utmcsr=
(direct)|utmccn=(direct)|utmcmd=(none)&__utmv=-&__utmk=100666753
</code>

The Google query string parameters were appended at the end of our query string, but with a “#” separator. Not exactly what we were expecting.

A cheap, quick and dirty fix is obvious: replace the “#” with a “&” and be on our way. But keep in mind that a simple replacement may create a problem with existing query string variables if being built dynamically, since we must have a “?” to start the query string parameters and must separate them with a “&” in a URL.

One solution is to extract the existing query string variables first, then call the GA function, then deal with the #/?/& issue,  and then append the old variables at the end.  We update our function to take care of this below:

<code>
function GoogleAnalyticsCookieAppend(uri)
{
//grab existing query string variables
var queryStringIndex = uri.indexOf('?');
var queryString =(queryStringIndex == -1) ? "" : uri.slice(queryStringIndex+1);
var myURI = (queryStringIndex == -1) ? uri : uri.slice(0, queryStringIndex-1);
//Use the Google Analytics function to get GA variables
var c = pageTracker._getLinkerUrl(myURI, window);
//Explicitly check in case GA is using #
c = c.replace("#", "?");
alert(c);
//reappend querystring variables
c += "&"+ queryString;
return c;
}
</code>

And that’s it for this mini-series on exploring the ins and outs of Google Analytics with non-standard tracking across top level domains.  Happy Google Analytics-ing!

Go to Part 1 or Part 2

    Sharing is caring!

    Popular

    COVID-19 Crisis Navigator​

    In partnership with Dentsu, Cardinal Path helps you distill the overwhelming news and information into a bi-weekly report highlighting emerging trends and insights during the pandemic.

    EXPLORE THE REPORT

    Analytics Rising Logo

    FREE VIRTUAL EVENT

    October 14

    Practical Strategies Delivered By Top Minds in Digital Marketing

    Register for #AnalyticsRising and get a Starbucks Gift Card when you share the news.

    Message Sent

    Thank you.

    Click here to download access the tool.

    Message Sent

    Thank you for registering.

    Message Sent

    Thank you for registering.

    Message Sent

    Thank you for registering.

    Message Sent

    Thank you for registering.

    Message Sent

    Thank you for registering.

    Message Sent

    Thank you for registering.

    Message Sent

    Thank you for registering.

    Message Sent

    Thank you for registering.

    Message Sent

    Thank you for registering.

    Message Sent

    Thank you.

    Message Sent

    Thank you.

    Message Sent

    Thank you

    Message Sent

    Thank you

    Message Sent

    Thank you.

    Message Sent

    Thank you

    Message Sent

    Thank you.

    Message Sent

    Success!
    Your message was received.

    Thank you.

    Message Sent

    Thank you for registering.

    Thank you for submitting the form.

    Thank you for your submission.

    Thank you for your submission.

    Thank you for your submission.

    Message Sent

    Thank you for registering.

    Thank you for your submission.

    Message Sent

    Thank you for registering.

    Thank you for registering.​

    Paid media spend by Government websites increased a whopping 139% YoY in 2020.

    2020 Online Behavior Live Dashboard

    Message Sent

    Thank you for registering.

    Message Sent

    Thank you for registering.

    Message Sent

    Thank you for registering.

    2020 Online Behavior Live Dashboard

    Message Sent

    Thank you for registering.

    Thank you for submitting the form.

    Message Sent

    Thank you for registering.

    Message Sent

    Thank you for registering.

    Message Sent

    Thank you for registering.

    Message Sent

    Thank you for your submission.

    Message Sent

    Thank you for registering.

    Message Sent

    Thank you for registering.

    Thank you for registering.

    Cardinal Path is continuing with its series of free training. Next we are conducting training on Google Data Studio. Check it out here.
    Cardinal Path hosted a live session to connect with you and answer all your questions on Google Analytics.
    Get all the expertise and none of the consultancy fees in this not-to-be-missed, rapid-fire virtual event.

    Message Sent

    Success! Thank you
    for reaching out.