Google Analytics(分析)跨网域跟踪无法使用 [英] Google Analytics Cross Domain Tracking does not work

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

问题描述

当访问者尝试预订时,网站会将其引导至预订引擎网站。

When a visitor tries to do a booking, the site directs him/her to the booking engine site.

ga('create', 'UA-XXXXXXXX-Y', 'auto', {'allowLinker': true });

ga('require', 'linker');

ga('linker:autoLink', ['mysite.com', 'bookingengine.com'], true, true);

ga('require', 'displayfeatures');

ga('require', 'linkid');

ga('send', 'pageview');

没有错误或警告。

我使用一个cookie监视器,它显示,浏览器在加载预订引擎站点时创建另一个新的_ga cookie。不使用相同的Cookie ID。

I used a cookie monitor and it shows that browser creates another new _ga cookie when it loads the booking engine site. The same cookie ID is not used.

我在努力将代码更改为 ga('linker:autoLink',['mysite.com ','bookingengine.com'],false,true); 但是它不工作。

I was struggling for days changing code to ga('linker:autoLink', ['mysite.com', 'bookingengine.com'], false, true); but it did not work.

推荐答案

p>好吧,我看到了问题。如果您在主要网站上填写表单并点击,您会看到_ga参数未附加到调用预订引擎的网址。由于参数是必需的,以便将clientid传输到其他网站(由GA提取并用作clientid),因此跨网域跟踪无法正常工作 - 预订引擎上的GA代码在传入的网址中找不到_ga参数url等等开始一个新的会话。

Okay, I see the problem. If you fill in the form on your main site and click you see the _ga parameter is not appended to the url that calls the booking-engine. Since the parameter is necessary to transfer the clientid to the other site, where it is picked up by GA and used as clientid, cross-domain tracking cannot work - the GA code on the booking-engine does not find a _ga parameter in the incoming url and so starts a new sessions.

通常autolink插件会添加参数到表单动作。这在你的情况下不工作,因为表单实际上通过JQuery函数提交(bookNow()在你的functions.js文件)。这将阻止链接器函数拦截submit事件并添加参数。

Usually the autolink plugin would add the parameter to the forms action. This does not work in your case since the form is actually submitted via a JQuery function (bookNow() in your functions.js file). This prevents the linker function from intercepting the submit event and adding the parameter.

解决方案是自己添加 - 从tracker对象获取链接器参数( tracker.get('linkerparam'))并将其添加到表单操作,并将其添加到booknow()函数中的重定向网址。

The solution would be to add it yourself - get the linker parameter from the tracker object (tracker.get('linkerparam')) and add it to the form action and add it to the redirect url in the booknow() function.

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

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