I\'m writing a web application that\'s supposed to be embedded in other people\'s websites (kind of a widget). I\'m using Google Analytics to track all the people that visit
This person is having the same problem on the Google Analytics help fourm. I'd suggest taking a look at the thread. But regularly GA doesn't support multiple trackers.
I like Clicky myself, but it costs money.
According to the documentation listed by Török, it seems the correct answer is to use _setCookiePath. This causes each tracker to use completely different cookies.
Example code from website:
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(”UA-11111-1″);
pageTracker._setDomainName(’domain.com’);
pageTracker._setCookiePath(’/subdirectory/’);
pageTracker._trackPageview();
var otherTracker = _gat._getTracker(”UA-22222-1″);
otherTracker._setDomainName(’domain.com’);
otherTracker._trackPageview();
</script>
When you link from one domain to another, every link that posts to the other domain has to look like this:
<a href="pageTracker._linkByPost('otherdomain.com/petStoreCart/legalTerms.php');"
This will add Google Analytics specific query string values that will be used by the above script to set the cookie (source).
I have used this structure on our site and clients sites and it works like a charm...
<script type="text/javascript">
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">
try {
//Original tracking
var pageTracker_ORIG = _gat._getTracker("UA-XXXXXXX-1");
pageTracker_ORIG._setDomainName('.sleepinggiantmedia.co.uk');
pageTracker_ORIG._trackPageview();
//New Analytics tag
var pageTracker_SGM = _gat._getTracker("UA-XXXXXXX-1");
pageTracker_SGM._setDomainName('.sleepinggiantmedia.co.uk');
pageTracker_SGM._trackPageview();
} catch(err) {}