WebShare is now Cardinal Path! www.CardinalPath.com
Learn more about Cardinal Path
Contact Us
Get an RSS feed of WebShare's blog
RSS Feed
Follow WebShare on Twitter!
Follow WebShare on Twitter
WebShare's Search and Conversion Marketing Newsletter
Email Newsletter

Search & Conversion Marketing Blog

Welcome to our blog! Here you'll find posts on the topics of web design & traffic acquisition, paid and organic search strategies, analytics & business intelligence, conversion testing, interviews, videos and more. We hope you find it useful, and invite you to read, share, subscribe, leave a comment, or just have a look at what's here.

Enabling cross domain tracking with unsupported navigation – Part 3

Saturday, June 21st, 2008 by Adrian Vender
Google Buzz

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




    Adrian Vender
    Adrian is a technical lead and search engine optimization expert at WebShare. You can find out more about Adrian here.

    See more posts by Adrian Vender

    Leave a Reply



    WebShare is a Google Analytics Authorized Consultancy
    WebShare is a Google Website Optimizer Authorized Consultancy
    WebShare is a Google Adwords Qualified Company
    WebShare is a Google Analytics Seminar Leader
    WebShare is a Google Website Optimizer Seminar Leader
    WebShare is a Google Urchin Authorized Consultant
    WebShare is a proud memeber of the Web Analytics Association
    WebShare is a Microsoft AdExcellence Member
    WebShare is a Yahoo Search Marketing Ambassador

    © 2006-2012 WebShare, LLC. All Rights Reserved.
    Sitemap