Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
568 views
in Technique[技术] by (71.8m points)

tracking - Google Analytics GIF request not sent

I'm having some troubles setting up Google Analytics. I downloaded the Google Analytics Debugging extension for Chrome and if I take a look at the console, the __utm.gif request is never sent. I triple-checked my code, and everything is fine. The debugging version of ga.js is downloaded properly. In fact, I have the exact same problem as this guy that never got an answer...

For the sake of it, here is my tracking code (with UA-########-# properly replaced in my original code, of course)

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

Everything is set up properly, and here is what I get in the console output :

_gaq.push processing : "[_setAccount, UA-########-#]"
_gaq.push processing : "[_trackPageview]"
Track Pageview

And then nothing else. I tried with a colleague's personal website that I know has Google Analytics installed and I can see the request for the .gif file.

Anyone ever had this problem ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Are you testing your site on localhost or an intranet? If so, you may need to add

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

before _trackPageview

See Google Analytics on Intranets and Development Servers for more info...

If you’re using Google Analytics on a site with a URL like http://intranet/ or something like http://mydevserver:12345 it won’t work.

Specifically, the Google Analytics JS code will not send the tracking hit (__utm.gif) to the GA servers.

I don’t really know the specifics, but I’m guessing that the domain hashing code looks for at least one period in the hostname and won’t work if it doesn’t find one.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...