在本地主机上测试Google Analytics [英] Test Google Analytics on Localhost

查看:125
本文介绍了在本地主机上测试Google Analytics的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用Google Analytics测试一些自定义触发事件。我想在当地环境中进行测试。



我使用服务器名称为apache设置测试网站: my-ga-test.localhost /

根据您可以在本地主机地址上测试Google Analytics(分析)吗? Google分析文档,我可以调整我的GA代码以使用:

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

我尝试设置一个新帐户以获取此网站的跟踪ID,但我出现以下错误:


URL以无效的顶级域名结尾




如何使用localhost域生成代码,以便我可以将跟踪ID代码更改为置于本地主机上?

创建新Google Analytics媒体资源时的网站网址字段不必与生产中使用的实际网址相同。它主要用于解析相关链接,而不是用于验证匹配。



只需将其更改为其他内容(如 example.com ),一切都应该正常工作。


I need to test some custom firing events using Google Analytics. I'd like to test in a local environment.

I've set up my test site using apache with server name: my-ga-test.localhost/

According to Can you test google analytics on a localhost address? and Google Analytics docs, I'm able to adjust my GA code to use:

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

I tried to set up a new account to get a tracking ID for this site, but I'm getting the following error:

URL ends with an invalid top-level domain name

How do I generate the code using localhost domain so I can alter the tracking ID code to put on my localhost?

解决方案

The "Website URL" field when creating a new Google Analytics property does not have to be the same as the actual URL that's used in production. It's primarily used for resolving relative links, not for validating hits.

Just change it to something else (like example.com), and everything should work fine.

这篇关于在本地主机上测试Google Analytics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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