I'm setting up multiple trackers to track 2 properties I setup in my Google Analytics. I found this link from Google which I use to set this up as the following:
ga('create', 'UA-XXXXXXX-6', 'auto');
ga('send', 'pageview');
ga('create', 'UA-XXXXXXX-8', 'auto', 'clientTracker');
ga('clientTracker.send', 'pageview');
However, when I search online I see people responding with the following:
ga('create', 'UA-XXXXXXX-6', 'auto');
ga('send', 'pageview');
ga('create', 'UA-XXXXXXX-8', 'auto', {'name': 'clientTracker'});
ga('clientTracker.send', 'pageview');
Should I be using just 'clientTracker' or {'name': 'clientTracker'} in my Universal tracking code?
Thank you!
Use the below code because it's descriptive:- {'name': 'clientTracker'}
Both are valid and do the same thing. The documentation indicates the
ga()
function's signature is:and https://developers.google.com/analytics/devguides/collection/analyticsjs/command-queue-reference#method-details indicates the
create
operation'sfields
are:The docs also note that:
so either way is valid, and the second way will override the first.