如何同时使用ga.js和analytics.js? [英] How to use both ga.js and analytics.js?

查看:99
本文介绍了如何同时使用ga.js和analytics.js?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将这两种方法都用于已经使用ga.js的现有Google acc ...我似乎找不到正确的文档。有经验的人吗?

How do i use both for an existing google acc that has been using ga.js...i cant seem to find the right documentation. anyone with experience in this?

推荐答案

要解释皮特所说的话。

为analytics.js创建新的网络媒体资源
-在您的Google Analytics(分析)帐户中,转到管理部分,然后创建新的网络媒体资源
-创建新的媒体资源将为您提供新的跟踪ID

Create a new web property for analytics.js - In your google analytics account, go to Admin section and Create a new web property - Creating a new property will provide you with a new Tracking ID

双重标记
-添加您的ga.js和analytics.js跟踪代码。请注意,它们不得共享相同的UA代码。您的代码可能如下所示:

Dual Tag - Add both your ga.js and analytics.js tracking code. Note that they must not share the same UA code. Your codes may look something like below:

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxx-y']);
_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>
<script>
  (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-xxxxx-z', 'yoursite.com');
  ga('send', 'pageview');
</script>

这篇关于如何同时使用ga.js和analytics.js?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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