Mobile app version of vmapp.org
Login or Join
Murray155

: How do you track a website using multiple Google Analytics accounts? Suppose you have two distinct Google Analytic accounts. How are you able to send request data to both accounts on a single

@Murray155

Posted in: #Google #GoogleAnalytics #Tracking

Suppose you have two distinct Google Analytic accounts. How are you able to send request data to both accounts on a single page load? For example, on a normal account you'd include code such as:

var _gaq = _gaq || ["UA-12345678-1"];
_gaq.push(['_setAccount', '']);
_gaq.push(['_setDomainName', 'none']);
_gaq.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);
})();


Could I simply include another snippet with a different UA ID? Can I pass several UA IDs in one request? Is this even possible to accomplish? Any help would be greatly appreciated!

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Murray155

1 Comments

Sorted by latest first Latest Oldest Best

 

@Rambettina238

You can use one GA snippet to send data to two different trackers. Follow the syntax below from the [Asynchronous Tracking Usage Guide][1:

_gaq.push(
['_setAccount', 'UA-XXXXX-1'], //default tracker, unnamed
['_trackPageview'],
['b._setAccount', 'UA-XXXXX-2'], //second tracker, named 'b'
['b._trackPageview']
);

code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html#MultipleCommands
Additional trackers are created by giving them names and prepending the tracker name (along with a dot) in front of the method name. The example above uses the aribrary name 'b'. If a function name is qualified with the name of a tracker, it is executed on that tracker. Otherwise it is executed on the default tracker.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme