我必须在本地机器上测试我的新GA帐户。
仅仅通过将谷歌提供的标准代码片段复制到页面上就可以工作吗?
我不想花24小时等着看它是否有效。
我必须在本地机器上测试我的新GA帐户。
仅仅通过将谷歌提供的标准代码片段复制到页面上就可以工作吗?
我不想花24小时等着看它是否有效。
当前回答
2014年更新
这现在可以通过简单地将域设置为none来实现。
ga('create', 'UA-XXXX-Y', 'none');
见:https://developers.google.com/analytics/devguides/collection/analyticsjs/domains localhost
其他回答
监控跟踪标签的一个更简单的工具是使用Chrome扩展(可能可用,或其他浏览器的等效)-谷歌标签助手。这将显示什么标签正在发射,它发现了什么问题,甚至打破东西,如电子商务价值,以方便阅读。还可以使用谷歌标签管理器,并可以处理页面上的多组标签。
以下是Tuong Lu Kim的回答:
假设:
ga(“create”、“aa - xxxxx - y”、“auto”);
...如果analysis .js检测到你在本地运行一个服务器(例如localhost),它会自动将cookie域设置为“none”....
摘录:
自动cookie域配置将_ga cookie设置在最高级别域上。例如,如果您的网站地址是blog.example.co。js将cookie域设置为。example.co. Uk。此外,如果analysis .js检测到你在本地运行一个服务器(例如localhost),它会自动将cookie域设置为“none”。 推荐的JavaScript跟踪代码片段为cookieDomain字段设置字符串'auto':
来源:https://developers.google.com/analytics/devguides/collection/analyticsjs/cookies-user-id automatic_cookie_domain_configuration
在花了大约两个小时试图想出一个解决方案后,我意识到我有广告拦截器阻止我打电话给GA。一旦我把它们关掉,我就可以走了。
2014年更新
这现在可以通过简单地将域设置为none来实现。
ga('create', 'UA-XXXX-Y', 'none');
见:https://developers.google.com/analytics/devguides/collection/analyticsjs/domains localhost
I just want to add to what's been said so far, it may save a lot of headache, you don't need to wait 24 hour to see if it works, yes the total overview take 24 hour, but in Reporting tab, there is a link on left side to Real-Time result and it will show if anyone currently visiting your site, also I didn't have to set 'cookieDomain': 'none' for it to work on localhost, my setting is on 'auto' and it works just fine (I'm using MVC 5), on top of that I've added the script at the end of head tag as google stated in this page:
将您的代码片段(未更改,完整)粘贴到您想要跟踪的每个网页。将它粘贴在</head>结束标记之前。
这里有更多关于如何检查分析是否正常工作的信息。