Google Analytics Not Tracking Data on Your Website? Could be a JavaScript Error.

This fix wont solve all Google Analytics tracking problems but it does address a specific issue. Outside of this problem, there are many other issues including disabled cookies, disabled JavaScript etc. that cannot be helped or fixed. If you have an existing website and Google Analytics is installed properly but is not collecting data please read on.

I recently talked to a new customer with an existing website. Her website was working great and was bringing in lots of business, however, no matter what she did she could not get Google Analytics to work on her website. The website was well designed, and modern, the Google Analytics tracking code was installed properly and the code did not contain any errors. I was perplexed so I started digging deeper.

The Solution:

After reviewing her code and analyzing her website I started reviewing the source code to see if some of the other JavaScript was somehow interfering with the Google Analytics. This was not the problem, but the problem was directly related to JavaScript. Some of the JavaScript code copy and pasted from another source contained a small syntax error. This syntax error occurred early in the page and was preventing the rest of the on page JavaScript including Google Analytics from being executed. The error, didn’t however effect the user experience and had gone unnoticed by her previous development company. Once we repaired the issue Google Analytics begin to function as expected.

Note: If you think this may be your problem I would suggest installing the web developer toolbar for Firefox. It has a fantastic error and warning notification system that will help you find and debug these types of errors.

No related posts.

If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.

Comments

Hi Ryan, just wanted to pipe in with a ‘thank-you’ for this post. After banging my head against a wall, convinced that a problem we were having with Google Analytics was caused by PHP we were using, I tried checking to see if JS could be at fault — and it was.

Even though all the scripts seemed to be behaving as they should, Firebug alerted us to some JS errors that were being thrown. Once fixed (ugh, fun challenge there), GA started tracking traffic for us.

Thanks for the tip!

Glad to hear the post helped. I am just glad Firebug exists or else this would be a really tricky one to solve. :)

Interesting I have found more and more problems since the latest release of Google Analytics. I have a problem with a site right now and have double checked every bit of code but yet it still does not work. I have over 300 sites running Google Analytics but yet this is the first time no mater what I did it does not work. I have had some where if the code was spaced incorrectly it didn’t work and I had to reinstall the code. The site I have now the won’t work I have been working on for a little over an hour to no luck.

Have you had anyone else that no mater what they do it doesn’t work? When I find out what is causing this problem I will get back to you on what was the problem.

Craig

Hi,

I heard that you can somehow get data on a new google google analytics account from BEFORE the GA JaveScript code was installed on every page of the site.

Is this possible, or am I totally wrong?

Many thanks,

Louise.

Leave a comment

(required)

(required)