03 Apr
By making some modifications to the GA code it is possible to send data to two Analytics accounts from one web page.
For urchin.js:
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-XXXXXXX-1"; urchinTracker(); _uff = 0; // Reset flag to allow for second account _uacct = "UA-XXXXXXX-2"; </script>
For ga.js:
<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"> var firstTracker = _gat._getTracker("UA-XXXXXXX-1"); firstTracker._initData(); firstTracker._trackPageview(); var secondTracker = _gat._getTracker("UA-XXXXXXX-2"); secondTracker._setDomainName("none"); secondTracker._setAllowLinker(true); secondTracker._initData(); secondTracker._trackPageview(); </script>
Please note: this applies to XHTML Transitional doctype written in utf-8 encoding. You may also download this post as a plain text file for easy copy & pasting.
Enjoy!
5 Responses
Gabe Hoggarth
04|Apr|2008 1Thanks, works great! Just had to fix the ” marks when I copied and pasted.
del.icio.us bookmarks for chrisjroos
14|Apr|2008 2Tracking Data for Multiple Google Analytics Accounts on One Page by SEOjeff…
Blog post detailing the changes required to the Urchin/GA javascript to allow you to record visits in multiple GA accounts. Possibly useful if you have multiple Adwords accounts that you want to link to Analytics accounts….
admin
14|Apr|2008 3Gabe, thanks for the heads-up. I’ve edited the post and have provided a plain txt version.
-Jeff
Anti Wrinkle Cream Guy
12|Jun|2008 4Thanks for the code.
I get an error in IE 7 though…
Says ” ‘_gat’ is undefined”
Tks again
Steve
11|Nov|2008 5Hey thanks for the script,
on ga.js I was getting the same error as ‘Anti Wrinkle Cream Guy’ but I removed your top script and replaced it with the one supplied by google. This worked which lead me to notice that when I had pasted the script the apostrophes were weird slanted ones. Something people should look out for as I think this will break the script.
Thanks Again,
Steve
Leave a reply
Search
About Jeffrey Nichols
My Twitter Feed
Tags
Recent Posts
Categories
Meta
Copyright © 2008 - SEOjeff.com - is proudly powered by WordPress