最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin3浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论