pahanix & IT

yet another passionate programmer

Notes &

Google Analytics. Asynchronous Tracking. Multiple Tracker Objects

Multiple Tracker Objects

As mentioned above, the creation of tracker objects is implied. They are created the first time you use them. The examples above only show how to used the default tracker object. If you need more tracker objects, you must prepend a unique name to the method name of each command array you push for non-default trackers. For example, the following code sets the account and calls _trackPageview() for the default tracker; then it does the same thing for a second and third tracker.

_gaq.push(['_setAccount', 'UA-XXXXX-1']);
_gaq.push(['_trackPageview']);

_gaq.push(['t2._setAccount', 'UA-XXXXX-2']);
_gaq.push(['t2._trackPageview']);

_gaq.push(['t3._setAccount', 'UA-XXXXX-3']);
_gaq.push(['t3._trackPageview']);

The names t2 and t3 are arbitrary. Asynchronous tracker names can be any valid Javascript string that doesn’t contain a dot (.). Also, using the default tracker is not mandatory. You can give all of your trackers names if you you prefer.

Filed under google analytics