使用多个跟踪器的Google Analytics(分析)跨域跟踪 [英] Google Analytics Cross-Domain Tracking with Multiple Trackers

查看:495
本文介绍了使用多个跟踪器的Google Analytics(分析)跨域跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站网络,它们都位于不同的域和子域(domain1.com,sub.domain1.com,domain2.com,sub.domain2.com)上。其中有些已安装Google Analytics(分析)追踪程式。有些没有GA跟踪器。

I have a network of sites that are all on different domains and subdomains (domain1.com, sub.domain1.com, domain2.com, sub.domain2.com). Some of them already have Google Analytics trackers installed. Some do not have GA trackers at all.

我想创建一种方法来查看跨网域的整个网络的单个Google Analytics(分析)帐户,而不会中断现有的单一 - 域GA跟踪。此外,我需要能够跟踪网络中各网站的访问次数和转化次数,就像它们是单个网站一样。基本上,您可以将其视为一个完全独立的GA帐户,用于网络。

I'd like to create a way to see a single GA account for the whole network, across domains, without disrupting existing single-domain GA tracking. Additionally, I need to be able to track visits and conversions across sites in the network as though they were a single site. Basically, you could think of it as a totally separate, independent GA account for the network.

我已经看到可以自动链接域=https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#autolink =nofollow> https://developers.google.com/analytics/devguides/collection/analyticsjs/跨域#autolink ),从而实现网络范围的分析和转换跟踪,但有办法做到这一点,不会打断现有的跟踪器已经在网站上?也许有一种方法让GA创建两个跟踪器与不同的cookie,其中之一是跨域?

I've seen that it's possible to auto-link domains (https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#autolink), thereby enabling network-wide analytics and conversion tracking, but is there a way to do this that won't disrupt the existing trackers already on the sites? Perhaps there's a way to make GA create two trackers with different cookies, one of which is cross-domain?

理想情况下,我可以给每个网站的开发人员一段代码添加到他们的网站,将启用网络跟踪。是可能吗?

Ideally, I could give each site's developer a snippet of code to add to their site that would enable the network tracking. Is it possible?

推荐答案

是的,这是可能的。请注意以下几点:

Yes, this is possible. A couple of things to keep in mind though:


我有一个网站网络,这些网站都位于不同的网域和子网域(domain1.com) ,sub.domain1.com,domain2.com,sub.domain2.com)。其中有些已安装Google Analytics(分析)追踪程式。有些没有GA跟踪器。

I have a network of sites that are all on different domains and subdomains (domain1.com, sub.domain1.com, domain2.com, sub.domain2.com). Some of them already have Google Analytics trackers installed. Some do not have GA trackers at all.

这不应该是一个问题。向现有页面添加第二个跟踪器很简单。

This shouldn't be a problem. Its simple to add a second tracker to an existing page. I'll show you how below.


我想创建一种方法来查看整个网络的单个GA帐户

I'd like to create a way to see a single GA account for the whole network

自动链接器插件实际上只能在属性级别,因此这些将不仅必须共享同一个帐户,但他们必须共享相同的属性。

The auto-linker plugin actually only works at the property level, so these will not only have to share the same account, but they'll have to share the same property. But this is probably what you want.


我需要能够跟踪网络中各网站的访问次数和转化次数,就像他们是单站点。基本上,您可以将其视为一个完全独立的GA帐户,用于网络。

I need to be able to track visits and conversions across sites in the network as though they were a single site. Basically, you could think of it as a totally separate, independent GA account for the network.

确切地说,您将创建一个品牌新的属性只是为了这个目的,跟踪所有这四个网站作为一个单一的网站。

Exactly, you'll create a brand new property just for this purpose, to track all four of these "sites" as a single "site".


也许有一种方法

Perhaps there's a way to make GA create two trackers with different cookies, one of which is cross-domain?

您可以创建在同一网站上运行的多个跟踪器,但必须共享Cookie 。这是因为analytics.js只将客户端ID存储在Cookie中,显然客户端是相同的。

You can create multiple trackers running on the same site, but they must share cookies. This is because analytics.js only stores the client ID in the cookie, and obviously the client is the same.

对于已安装分析工具的现有网站,代码可能看起来像这样:

For one of your existing sites that already has analytics installed, the code probably looks something like this:

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-XXXX-Y', 'auto');
ga('send', 'pageview');

要向跟踪不同属性的页面添加其他跟踪器,您只需添加一些行的JavaScript到代码段。在此示例中,您向新的跟踪器提供名称 t2 ,因此不会干扰现有跟踪器。

To add another tracker to that page that is tracking a different property, you can just add a few more lines of JavaScript to the snippet. In this example, you're giving your new tracker a the name t2 so it doesn't interfere with the existing tracker.

ga('create' 'UA-YYYY-Z', 'auto', {name: 't2'});
ga('t2.send', 'pageview');

这将创建一个新的跟踪器,并使用新的跟踪器发送一次网页浏览,自动链接。要做到这一点,你必须稍微修改它(假设这个代码是为domain1.com):

This creates a new tracker and sends a pageview with the new tracker, but it doesn't set up autolinking. To do that you'll have to modify it slightly (assume this code is for domain1.com):

ga('create', 'UA-YYYY-Z', 'auto', {name: 't2', allowLinker': true});
ga('t2.require', 'linker');
ga('t2.linker:autoLink', ['domain2.com']);
ga('t2.send', 'pageview');

然后对于domain2.com,您只需稍微更改代码以自动链接到domain1。 com:

And then for domain2.com you'll just have to change the code slightly to autolink to domain1.com:

ga('create', 'UA-YYYY-Z', 'auto', {name: 't2', allowLinker': true});
ga('t2.require', 'linker');
ga('t2.linker:autoLink', ['domain1.com']);
ga('t2.send', 'pageview');

您不需要列出子域,因为analytics.js默认跟踪这些子域。

You don't need to list the subdomains because analytics.js tracks those by default.

除了您提供的链接,以下是有关跨网域跟踪的一些更有用的信息:

https://support.google.com/analytics/answer/1034342?hl=zh-TW

In addition to the link you provided, here's some more helpful information about cross-domain tracking:
https://support.google.com/analytics/answer/1034342?hl=en

这篇关于使用多个跟踪器的Google Analytics(分析)跨域跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆