fbpx

Google Analytics and Multiple Websites with Preloader Page

Google Analytics and Multiple Websites with Preloader Page

A while ago, a client had asked us how to track a landing page that redirected to two distinct company websites in two different languages, each one with separate Google Analytics accounts. Also, how would they be able to track user activity on a shopping cart that was off-site. Our answer was as follows.

1. One solution would be to create a “rollup” code and apply this Google  Analytics tracking code to all pages. This actually would help with tracking the shopping cart as well. The code to modify would be as follows:

<script type="text/javascript">// <![CDATA[
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
// ]]></script>
<script type="text/javascript">// <![CDATA[
try { var pageTracker = _gat._getTracker("UA-AAAAAAAA-1"); pageTracker._setDomainName("none"); pageTracker._setAllowLinker(true); pageTracker._trackPageview(); var rollupTracker = _gat._getTracker("UA-XXXXXXXX-1"); rollupTracker._setDomainName("none"); rollupTracker._setAllowLinker(true); rollupTracker._trackPageview(); } catch(err) {}
// ]]></script>

2. Another way to track these domain names, according to Google, would be to add the following Google Analytics tracking code below “var pageTracker=xxxxxx:”

pageTracker._setDomainName(“none”);
pageTracker._setAllowLinker(true);

google analytics

Technically, Google Analytics stores a cookie on ones computer in order to track your activity. A cookie normally cannot transfer over to another domain. By setting “setDomainName” to “none,” you’re leaving the cookie open for duplication to another website. “setAllowLinker,” set to “true,” allows any URLs to link to a different domain, carrying the “cookie” data over.

After that, change the linking. It was noticed noticed that on the home page, the URLs point to http://www.clientwebsite.com/ck_add.asp?ck=xx where “ck,” or “cookie,” can either equal “lang1” or “lang2.” It would be suggested that, instead of making the “add cookie” function on a separate page, add that to the top of each site page as an “include.” If no cookie is created, create a cookie based on the domain the person is on.

Once that is done, change the URL from <a href=”ck_add.asp?ck=lang1″ target=”_parent”>Country1</a> to something like:

<a onclick=”pageTracker._link(this.href); return false;” href=”http://www.clientwebsite.com.foo” target=”_parent”>Country</a>

This “onclick” action should then duplicate the cookie onto a completely different domain. The only downside to this, though, is that it only tracks for one profile.

So there you have it. Feel free to add comments and/or suggestions on other ways to track multiple websites with Google Analytics

By |2010-08-13T12:56:52-04:00August 13th, 2010|

About the Author: