Can you test google analytics on a localhost addre

2020-01-23 13:04发布

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.

12条回答
等我变得足够好
2楼-- · 2020-01-23 13:52

I came across this problem recently, and I found it helpful to explore the new documentation by Google on debugging Analytics. It didn't actually care about sending tracking info to Google Analytics, I just wanted to ensure that the events were firing correctly, and the debugging tools gave me the info I needed. YMMV, I realize doesn't exactly answer the question.

查看更多
我只想做你的唯一
3楼-- · 2020-01-23 13:57

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:

Paste your snippet (unaltered, in its entirety) into every web page you want to track. Paste it immediately before the closing </head> tag.

here is more info on how to check to see if analytics works properly.

查看更多
叼着烟拽天下
4楼-- · 2020-01-23 13:58
Juvenile、少年°
5楼-- · 2020-01-23 13:58

An easier tool to monitor the tracking tags is to use the Chrome extension (probably available, or the equivalent for other browsers) - Google Tag Assistant. This will show what tags are firing, what problems it has found, and even breaks out stuff like eCommerce values for easy reading. Also works with the Google Tag Manager, and can handle multiple sets of tags on the page.

查看更多
别忘想泡老子
6楼-- · 2020-01-23 13:59

I had the same problem, and all the solutions didn't work until I did two things:

Obvious code:

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXXXX-X']);
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);   
_gaq.push(['_trackPageview']);

AND

I added localhost another FQDN - domain name. I did this on Windows sistem by editing:

C:\Windows\System32\drivers\etc\hosts

file, and I put in the following:

127.0.0.1   my.domain.org

Then I went to address http://my.domain.org/WebApp that is serving page with included google analytics JS.

If you are on unix, edit /etc/hosts for same result.

It think that Google should put Intranet configuration in ther GA FAQ. They just say that you need FQDA. Yes, you do, but not for them to access you, you need it just to have Host attribute in HTTP request.

I think another reason for FQDN is COOKIES! Cookies are used to track data and if you don't have FQDN, cookie can not be set, and JS code stops and doesn't get the gif.

查看更多
Rolldiameter
7楼-- · 2020-01-23 13:59

After spending about two hours trying to come up with a solution I realized that I had adblockers blocking the call to GA. Once I turned them off I was good to go.

查看更多
登录 后发表回答