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 1

Wednesday, June 18th, 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 figuring out how to use Google Analytics on a site that spans multiple top level domains, (i.e. transfer cookies across multiple domains) there are many good resources out there (books, blogs, helpfiles and more). Given the amount of work done on this topic and the frequency with which it occurs on websites, you might not think this would be a difficult problem, and in most common cases, it isn’t.

But while there are well documented and standard methods that specifically deal with hyperlinks and HTML forms, you may find yourself in some unfamiliar territory if your site uses other types of navigation methods (scripted redirects, server side, etc…).

Take, for example, the simple snippet below:

<code>
<a href="" onclick="redirectFunction()">Link across top level domains</a>
function redirectFunction()
{
window.location.replace('http://www.xxx.yyy/RedirectTarget.html');
}
</code>

To address this one, you might write a wrapper function that encapsulates the redirect and inserts a call to the pageTracker._link(<urlToRedirectTo>) function, so we’d do something like the following:

<code>
function redirectFunction()
{
window.location.replace(GoogleAnalyticsCookieAppend('http://www.xxx.yyy/
RedirectTarget.html'));
}
function GoogleAnalyticsCookieAppend(uri)
{
pageTracker._link(uri);
return uri;
}
</code>

Note: You’ll want to make sure to include the “return false” at the end of your call here.

This will work for cases where we have a hyperlink (anchor tag) doing this direct javascript call, as follows:

<code>
<a href="" onclick="GoogleAnalyticsCookieAppend('http://www.xxx.yyy/
RedirectTarget.html');return false;"> This one tries indirectly  </a>
</code>

But what about something that’s not a hyperlink, like a div container?

<code>
<div id="mydiv" onclick="redirectFunction();return false;">
Content for this container
</div>
</code>

This is neither a hyperlink nor a form, and our attempts at solving this problem with pageTracker._link() and pageTracker._linkByPost() just don’t seem to work…

Continue to 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

One Response to “Enabling cross domain tracking with unsupported navigation – Part 1”

  1. Tony Brown says:

    I don’t know If I said it already but …Hey good stuff…keep up the good work! :) I read a lot of blogs on a daily basis and for the most part, people lack substance but, I just wanted to make a quick comment to say I’m glad I found your blog. Thanks,)

    A definite great read..Tony Brown

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 proud memeber of the Web Analytics Association
WebShare is a Microsoft AdExcellence Member
WebShare is a Yahoo Search Marketing Ambassador

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