Google Analytics(分析) - 将第三方购物车添加到主域报告中

时间:2016-06-09 17:19:06

标签: google-analytics

我们想跟踪从我们的主网站发送到第三方网站的用户是否已退回或点击“注册” 他们愿意将我们的Google Analytics代码放在他们的页面中 - 包括产品和注册。 我查看了谷歌的建议,但不清楚一些事情。

我们网站上的当前代码:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-nnnnn-1']);
  _gaq.push(['_setDomainName', 'none']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

Google建议您使用第三方网站的代码:

<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-12345-1']);
_gaq.push(['_setDomainName', 'my-example-blogsite.com']);
_gaq.push(['_setAllowLinker', true]);
_gaq.push(['_trackPageview']);
</script>
...
<a href="http://dogs.example-petstore.com/intro.html"
   onclick="_gaq.push(['_link', 'http://dogs.example-petstore.com/intro.html']); return false;">
   See my pet store</a>

我们的代码在这一行中有'none':_gaq.push(['_ setDomainName','none']);

Google的示例代码包含网址

_gaq.push(['_setDomainName', 'my-example-blogsite.com']); 

重要吗?我是否需要按照建议进入域名?

此外,Google的代码还有一个返回我们网站的链接,如下所示

onclick="_gaq.push(['_link', 'http://dogs.example-petstore.com/intro.html']); return false;"

我们需要链接回来吗?我们可以删除onclick代码还是会影响报告? 谢谢! Myalo

1 个答案:

答案 0 :(得分:0)

您需要onclick事件。它的作用是&#34;装饰&#34;该链接,即它将需要转移到其他域的URL参数添加到其他域(Google代码将其拾取并用于继续会话)。

请注意,您使用的代码非常过时。如果可能的话切换到当前版本(Universal Analytics)。虽然Universal Analytics上的跨域跟踪工作原理相同,但它更优雅(使用单个参数而不是经典GA的笨重查询字符串),并提供了许多辅助功能,使跨域跟踪更容易。

相关问题