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!

link|improve this question
feedback

migrated from superuser.com Aug 1 '11 at 6:44

This question came from our site for computer enthusiasts and power users.

1 Answer

up vote 5 down vote accepted

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']
);

http://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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.