如何使用 NEW analytics.js 跟踪多个帐户? [英] How to track multiple accounts using NEW analytics.js?

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

问题描述

我需要使用 Google 的新 analytics.js 在一个页面上跟踪两个帐户的综合浏览量.有很多教程和示例如何使用较旧的 ga.js 进行操作.但我发现的只是这个分析文档页面.我已经编写了适合给定示例的代码,但它只跟踪第一个(默认)跟踪器的视图,而不跟踪第二个.

I need to track pageview for two accounts on one page, using Google's new analytics.js. There is plenty of tutorials and examples how to do it with older ga.js. But all I have found was this Analytics documentation page. I have written my code to suit the given example, but it only tracks views for first (default) tracker, but not for the second one.

<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-XXXXXXXX-3', 'domain.com');
  ga('create', 'UA-ZZZZZZZZ-1', {'name':'b'});
  ga('send', 'pageview');
  ga('b.send', 'pageview');
</script>

有人知道我的代码有什么问题吗?根据 Google 的示例,我觉得不错.

Anyone has any idea what is wrong with my code ? Looks good to me according to Google's example.

推荐答案

您使用 analytics.js 进行多个帐户跟踪的代码是正确的,我已在我的站点中成功测试了类似的代码.因此,您需要检查以下任何可能的错误:

Your code for multiple accounts tracking using analytics.js is correct, I have successfully tested a similar code in my site. So you need to check the following for any possible error:

1、确认两个跟踪数据是否都发送.例如,在 chrome 中,使用 GA 调试器插件进行 chrome,然后在 javascript 控制台中,查看您是否获得了以下两个跟踪 ID 的详细信息

1, Confirm if both tracking data are sent. For example in chrome, use GA debugger plugin for chrome and then in javascript console, see if you are getting the below details for both your tracking ids

adSenseId        (&a)   425734287 
apiVersion       (&v)   1 
clientId         (&cid) xx.xx
encoding         (&de)  UTF-8 
flashVersion     (&fl)  11.8
hitType          (&t)   pageview
javaEnabled      (&je)  1 
language         (&ul)  en-us 
location         (&dl)  domain.com 
referrer         (&dr)
screenColors     (&sd)  24-bit
screenResolution (&sr)  1366x768
title            (&dt)  yourdomaintitle 
trackingId       (&tid) UA-XXXXXXXX-3 
viewportSize     (&vp)  1364x361 

理想情况下,您应该看到这一点,因为您的代码是正确的,这意味着您的网站正确发送了 2 个跟踪信号.

Ideally you should see this as your code is correct and this means your website is correctly sending 2 tracking signals.

2, 对于您的第二个跟踪 ID,请确保 跟踪 ID 与您的 GA 网络资产

2, For your second tracking id, ensure the tracking id is exactly same as the one in your GA web property

3, 确保您没有将任何过滤器应用到您的网络资产内相应的视图,这可能会过滤掉流量.如果您使用了一些过滤器,请查看未过滤的视图,看看您是否在实时概览中看到了点击率

3, Ensure you have not applied any filters to the corresponding view inside your web property which may filter out the traffic . Incase you are using some filters, take an unfiltered view and see if you are seeing hits in the realtime overview

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

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