简体   繁体   English

开发网站上的Google Analytics(分析)脚本

[英]Google analytics script on dev site

I'm setting up google analytis on my webpage using the standard script: 我正在使用标准脚本在网页上设置google analytis:

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);
  _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>

If I include this site on my UAT page (eg http://uatsite.com/ ) will google track any activity or will it only track activity on my main site (eg http://production-site.com ). 如果我在UAT页面上包含此网站(例如http://uatsite.com/ ),它将在Google上跟踪任何活动,或者仅跟踪我的主站点(例如http://production-site.com )上的活动。

thxs 谢谢

This will only collect analytics for the url you configured. 这只会收集您配置的网址的分析数据。 This will not collect from any other domain. 这不会从任何其他域收集。

The domain (or, as GA likes to call it, hostname ) from which Google Analytics receives its info doesn't matter and really it's up to the client to define it (and is very much exploited, see this for just one example). 域名(或如GA喜欢称呼它, 主机名 )从谷歌Analytics(分析)接收其信息并不重要,实际上它是由客户端来定义它(和非常多利用,看到只是一个例子)。

If you don't want to track activity on your UAT site, you can create a Hostname filter to prevent the data from being recorded. 如果您不想跟踪您的UAT站点上的活动,则可以创建一个Hostname过滤器以防止记录数据。 This filter can be of include type so that only your production site registers or exclude type so it excludes only your UAT site. 该过滤器可以是包含类型,以便仅您的生产站点注册或排除类型,以便它仅排除您的UAT站点。

Alternatively, you can modify your analytics code to not track on the UAT site: 或者,您可以修改您的分析代码以使其不在UAT网站上进行跟踪:

if (!/uatsite/.test(window.location.hostname)) _gaq.push(['_trackPageview']);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM