18

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 ?

marco-fiset
  • 1,933
  • 1
  • 19
  • 31

2 Answers2

37

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.

antony.trupe
  • 10,640
  • 10
  • 57
  • 84
mike
  • 7,137
  • 2
  • 23
  • 27
  • 1
    Thank you!!! Indeed I was testing on localhost. I did not think it made any difference. Now it works ! – marco-fiset Mar 16 '12 at 17:05
  • Does it matter if I leave that piece of code there when the site goes to production ? Is there an impact on the statistics ? – marco-fiset Mar 16 '12 at 17:25
  • If all the pages on your site are in one domain or sub-domain, then there's no problem leaving it in. – mike Mar 16 '12 at 19:17
  • Without this answer I would have been debugging pointlessly for probably another 2 days – d-_-b Oct 11 '12 at 03:16
  • +1 it also happens when the domain is wrong i.e. as when changing domains and missed changing that – eglasius Apr 29 '13 at 14:04
  • Also happens for _trackEvent when the 'label' is not a string (console reports Track Event but doesn't report beacon sent). – eglasius Apr 29 '13 at 14:12
  • Fixed my issue, too. Thought I was going crazy. Thank you! – Matt Dell Jul 04 '13 at 08:58
  • I don't remember this being an issue with the previous synchronous syntax using ga('send', 'pageview'). I never suspected this would be a localhost problem. Thank you! – Will Schoenberger Jul 23 '14 at 20:17
  • I am suffer the same issue in chrome extension development env, finnally, save save my life! – Huan Sep 12 '17 at 07:28
2

If you are not receiving the Tracking beacon sent! message then it could be one of the following:

  • A problem with Cookie settings in your browser (however unlikely in your case)
  • An issue with your proxy/firewall (can you check fiddler or your Network tab and see if any of your resources were 404'd?)
  • A javascript error (anything else at all in your console?)

Hope this helps you debug your situation. I'll update this answer if you provide any more information.

UPDATE

It may help to make sure that the issue is with the Chrome Analytics debugger plugin versus your analytics setup. To do this, open something like Fiddler or in Chrome under Resources - Frames - (page) - Images. You should see the request for __utm.gif there. If you do not, its an issue with your Analytics setup. If you do, its just an issue with the Chrome Analytics debugger.

To answer your question though, I've only seen something similar happen one other time and that was on a site with Google Ads. I received an Unsafe Javascript attempt to access frame with URL... error.

shanabus
  • 12,989
  • 6
  • 52
  • 78
  • This is the only output I get in the console. I already checked for 404'd resources and nothing there. Cookies are enabled, I am not behind a proxy. I disabled my firewall and it did not help. – marco-fiset Mar 16 '12 at 16:11