구글 애널리스틱 한페이지에 두개의 트래킹 아이디 먹히게 할때
https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced
Working with Multiple Tracking Objects
In some cases you might want to send data to multiple web properties from a single page. This is useful for sites that have multiple owners overseeing sections of a site; each owner could view their own web property.
To solve this, you must create a tracking object for each web property to which you want to send data:
ga('create', 'UA-XXXX-Y', 'auto');
ga('create', 'UA-12345-6', 'auto', {'name': 'newTracker'}); // New tracker.
Once run, two tracker objects will be created. The first tracker will be the default tracking object, and not have a name. The second tracker will have the name of newTracker
.
To send a pageview using both trackers, you prepend the name of the tracker to the beginning of the command, followed by a dot. So for example:
ga('send', 'pageview');
ga('newTracker.send', 'pageview'); // Send page view for new tracker.
Would send a pageview to both default and new trackers.
To access a tracker object by name within a function, you use the getByName
method:
ga(function() {
var newTracker = ga.getByName('newTracker');
});
To get an array of all the trackers that have been configured, use the getAll
method:
ga(function() {
var allTrackers = ga.getAll();
});