javascript - How to properly use multiple tracking IDs in Google Analytics - Stack Overflow

My current setup for Google Analytics looks like this:ga('create', 'UA-XXXXXXXX-1',

My current setup for Google Analytics looks like this:

ga('create', 'UA-XXXXXXXX-1', 'auto');
ga('require', 'displayfeatures');
ga('send', 'pageview');

I read this article explaining how to track data when using more than 1 tracking ID:

So using the examples in the link, I need to add the following lines of script:

ga('create', 'UA-XXXXXXXX-2', 'auto', 'myTracker2');
ga('myTracker2.send', 'pageview');

What do I do with displayfeatures? Do I need to prepend myTracker2 to it as well? Something like:

ga('myTracker2.require', 'displayfeatures');

My current setup for Google Analytics looks like this:

ga('create', 'UA-XXXXXXXX-1', 'auto');
ga('require', 'displayfeatures');
ga('send', 'pageview');

I read this article explaining how to track data when using more than 1 tracking ID:

https://developers.google./analytics/devguides/collection/analyticsjs/creating-trackers

So using the examples in the link, I need to add the following lines of script:

ga('create', 'UA-XXXXXXXX-2', 'auto', 'myTracker2');
ga('myTracker2.send', 'pageview');

What do I do with displayfeatures? Do I need to prepend myTracker2 to it as well? Something like:

ga('myTracker2.require', 'displayfeatures');
Share Improve this question asked Oct 27, 2016 at 8:07 Brendan VogtBrendan Vogt 26.1k39 gold badges150 silver badges235 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 7

as per developer pages:

Using Multiple Trackers

To use the display features plugin with multiple trackers, prepend the require call with the tracker name, as in this example:

// create a tracker named 'foo' for property UA-XXXXX-Y
ga('create', 'UA-XXXXX-Y', {name: 'foo'});
ga('foo.require', 'displayfeatures');
ga('foo.send', 'pageview');

// create a second tracker named 'bar' for a different property UA-XXXX-Z
ga('create', 'UA-XXXXX-Z', {name: 'bar'});
ga('bar.require', 'displayfeatures');
ga('bar.send', 'pageview');

Loading the display features plugin for a named tracker will result in the tracker name being appended to the cookie name. The above example would create the cookies _gat_foo and _gat_bar.

Link to source: https://developers.google./analytics/devguides/collection/analyticsjs/display-features

I hope this helps.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744794923a4594148.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信