Reputation: 11
My goal was to setup 2 trackings on each website : one specific to the website, and a second to aggregate the data of websites which belong to a network.
here is the code i implemented :
// UA-XXXXXXXX-1 = Global tracking
// UA-XXXXXXXX-2 = Specific tracking
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(["_setCustomVar", 1, "Type", "Value_Type", 1]);
_gaq.push(['_trackPageview']);
var _gaq2 = _gaq2 || [];
_gaq2.push(['_setAccount', 'UA-XXXXXXXX-2']);
_gaq2.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
This code is not working : specific tracking is not working. Any idea why ?
Thanks in advance
Upvotes: 1
Views: 241
Reputation: 32760
Your code should rather look like this:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
_gaq.push(["_setCustomVar", 1, "Type", "Value_Type", 1]);
_gaq.push(['_trackPageview']);
_gaq.push(['SPECIFIC._setAccount', 'UA-XXXXXXXX-2']);
_gaq.push(['SPECIFIC._trackPageview']);
Upvotes: 3