你可以在本地主机地址上测试谷歌分析吗? [英] Can you test google analytics on a localhost address?

查看:106
本文介绍了你可以在本地主机地址上测试谷歌分析吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在我的本地计算机上测试我的新GA帐户。

只需将Google提供的标准代码片段复制到网页上,这项工作是否可行?



我不想花24小时等待,看它是否会起作用。

解决方案

这个问题今天仍然有效,但技术已经改变。旧的Urchin跟踪器已弃用且已过时。新的异步Google Analytics(分析)跟踪代码使用略有不同的代码来实现相同的结果。 谷歌分析经典版 - 异步语法 - ga.js

在google analytics上将跟踪域设置为none的当前语法如下所示:

  _gaq.push(['_ setDomainName','none']); 

然后Google analytics会在localhost上触发_utm.gif跟踪器请求。您可以通过在您喜欢的浏览器中打开开发人员工具并在加载页面期间查看网络请求来验证此情况。如果正在运行,您将在网络请求列表中看到对_utm.gif的请求。



2013年Universal Analytics更新 - analytics.js



Google发布了名为Universal Analytics的新版分析工具(2012年末或2013年初)。在我撰写时,这个程序仍处于测试阶段,所以上述代码仍然适用于大多数已安装Google Analytics的用户。



然而,对于使用新的 analytics.js 代码, Google Analytics,高级配置 - 网络跟踪文档显示我们可以使用以下新代码在本地主机上测试Universal Analytics: c> ga('create','UA-XXXX-Y',{
'cookieDomain':'none'
});

查看链接文档以获取有关Universal Analytics高级配置的更多详细信息。


I have to test out my new GA account on my local machine.

Will this work just by copying the standard snippet supplied by Google onto the page ?

I don't want to spend 24 hours waiting to see if it will or won't work.

解决方案

This question remains valid today, however the technology has changed. The old Urchin tracker is deprecated and obsolete. The new asynchronous Google Analytics tracking code uses slightly different code to achieve the same results.

Google Analytics Classic - Asynchronous Syntax - ga.js

The current syntax for setting the tracking domain to none on google analytics looks like this:

_gaq.push(['_setDomainName', 'none']);

Google analytics will then fire off the _utm.gif tracker request on localhost. You can verify this by opening the developer tools in your favorite browser and watching the network requests during page load. If it is working you will see a request for _utm.gif in the network requests list.

Updated 2013 for Universal Analytics - analytics.js

Google released a new version of analytics called "Universal Analytics" (late 2012 or early 2013). As I write, this the program is still in BETA so the above code is still recommended for most users with existing installations of Google Analytics.

However, for new developments using the new analytics.js code, the Google Analytics, Advanced Configuration - Web Tracking Documentation shows that we can test Universal Analytics on localhost with this new code:

ga('create', 'UA-XXXX-Y', {
  'cookieDomain': 'none'
});

Check out the linked documentation for more details on advanced configuration of Universal Analytics.

这篇关于你可以在本地主机地址上测试谷歌分析吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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