code-review-tools

How to detect and resolve Google analytics errors on your website

Google analytics is an amazing tool that helps to collect data about users and their activity on your website. You can learn amazing things about your online audience such as their demographics (gender and age distribution), how much time they spend on your site, the type of pages they are most interested in, the number of pages they read before leaving and so on.

All of Google’s really cool data is only useful if it is reliable, and there are many reasons why the data that Google collects may be wrong. This is why it is necessary to ensure that your Google analytics codes are properly installed, and properly audited. Even without an audit, you can tell if your tracking code is faulty when you have:

  1. An unusually high or low bounce rate
  2. An unreasonably high or low number of page views, especially when ad revenue does not match the rise and fall in views
  3. When you have static data like time on page that doesn’t improve or diminish over several months.

All these are indicative of a faulty Google analytics implementation and these faults are due to certain errors which are fairly common.

To detect these sort of errors, tools like Google Analytics debugger and tag assistant come in handy.
The analytics debugger helps to analyze JavaScript events coming from your Google analytics tag right within your chrome console. The tag assistant extension usually looks like this.

Google tag assistant is a lot easier to work it as it gives a snapshot overview of all detected tags on a page and color codes them based on four characteristics which are:

  • When the tag is green, then this means that there are no implementation issues associated with it.
  • When the tag is blue, it means that there are minor implementation problems along with suggestions to correct those issues.
  • When the tag is yellow, this means that there are risks to your data quality and the tag setup is likely to give unexpected results.
  • When the tag is red, this means that there are outright implementation errors with the set up which could lead to missing data in your reports.

When using tag assistant, here are some common errors you could find

1. Invalid or missing web property ID

This usually happens when the property ID in your analytics code is either missing or wrong. The property ID is like a phone number that tells Google analytics the exact account it should send all the data it has collected to. So if the property ID is missing, data will be collected but won’t be sent to your analytics account.

Solution: Ensure that the web property ID on your page matches the ID in your Google analytics account. To be safe, just ensure that script on your page matches the script that is generated in your account.

2. Same web ID property is tracked twice

Source of the problem: This error usually results from multiple installations of your Google analytics property ID. This happens when Google analytics is reporting to the same web ID from the global site tag, googlr tag manager and Google analytics. It can also happen when Google analytics code from the same web property is installed through an external file and through a direct installation in the HTML of your website.

Solution: The solution is to ensure that the tracking code of each web property ID is only installed once. So you can look through your site’s source code. Use ctrl + F to find all instances of the web property. Identify the tags through which it’s injection into the page is being duplicated, then proceed to eliminate all but one of them.

3. Missing http response


This error indicates that while Google analytics has been detected on the page, it isn’t sending any responses to Google’s servers. Without a http response, data isn’t being transported to the server and hence, cannot appear in your analytics account.

Solution: Reinstall Google analytics in the head section of your website since this error usually results from faulty installations of the tracking code.

4. Method X has X additional parameters


Each method in Google Analytics has a set number of allowed parameters. You can find out the number and type of allowed parameters for any method by reading the documentation.

This error denotes that you have exceeded the number of allowed parameters for the given method.
Exceeding the number of allowed parameters will either cause Google Analytics to drop any parameter over the limit OR cause Google Analytics to fail to record data associated with the given method.

Solution: Review the documentation and parameter allocation for the respective Google Analytics methods and ensure that your implementation follows the documentation appropriately.

You can check Google’s documentation here

5. Leading or trailing whitespace in ID


This error indicates that your Google Analytics ID is not properly set within the setAccount function in the Google Analytics JavaScript. The error explicitly states the existence of a whitespace or empty space either before or after the account ID that is preventing the correct ID from being identified or collected. Your account ID is important because it indicates the account that the collected data is to be sent to.

Solution: Ensure that there is no space before, after or within your Google a analytics ID. Also check to ensure that the ID in your source code matches with the ID in your analytics account.

6. Move the tag inside the head


This error indicates that the analytics ID is not in the ideal location within your sites HTML. The ideal location for the analytics scripts is the head section because it is it the the head section that the tracking beacon is guaranteed to have fired before the visitor has left your site. If the tracking code is in the body or footer, it may not have fired, recorded a visit or any other event before the user would have left the page. It could also miss certain page events leading to missing and incorrect data in your reports.

Solution: Move your tracking code to the head section of your sites’ HTML and place it just a above the closing head tag
<head>
Place the code just above the closing head tag
</head>

Detected both dc.js and ga.js/urchin.js
Remove Depreciated method ‘XXXXX’

6. Missing JavaScript & Missing JavaScript closing tag


Without a closing tag, the JavaScript functions required to collect data from your page and transport it to Google’s servers would fail to execute.
When this happens, no data will be collected or reported in your account.

Solution: Ensure that your Google Analytics script contains the full request to google-analytics.com. Ensure that all functions are declared in full just as stated in the tracking code you were given. To be safe, just ensure that script on your page matches the script that is generated in your account.

7. Tag is included in an external script file

This message indicates that Google analytics isn’t present on the page source code but is firing from an external file. While data may still be reported, this sort of set up is fragile and could be responsible for data discrepancies. It might also make your site vulnerable to competitor spying or negative SEO attacks.

Solution: Check through the external file that your code is firing from and ensure that it is working properly. If you had prior problems before you discovered that an external file was hosting your tracking code, it may be best to install Google analytics in the source code of your website and remove it from the external file.

Conclusion


Data collection is extremely important in the optimization or day to day managing of a website. The data you collect can be analyzed to find what works, what doesn’t work, why it doesn’t work, when it doesn’t work and for whom it doesn’t work. This info can change the trajectory of your website for good only if the information your have is reliable. This is why Google analytics auditing is necessary and is something you should embark upon from time to time. If you have any further questions you would like to ask me, feel free to get in touch.

Leave a Reply

Your email address will not be published. Required fields are marked *