Debugging browser errors
December 1st, 2006 | Published in Google Analytics
Adding the Google Analytics tracking code to your website is easy—simply add the JavaScript snippet to the source code. But what happens when you make changes to your website and start to see browser error messages? Don't panic. Check these issues to avoid common mistakes.
1. Check the tracking code
Correctly installed Google Analytics tracking code does not generate browser errors. If you're seeing them, first check that your tracking code is installed exactly as it appears in your Google Analytics profile setting. Learn how to find your tracking code in the help center article Where Can I Find My Tracking Code?
2. Test your page
Google Analytics uses JavaScript code that is designed not to interfere with other JavaScript on your website. That said, when an error occurs, browser error messages often reference the first script executed. On a site using our tracking code, that is usually the first script executed, which makes debugging confusing. When debugging JavaScript on a site tracked by Google Analytics, try commenting out or temporarily removing the tracking code until you can detect and correct the error. Once your code is bug-free, adding the tracking code back in should not cause any browser errors to occur.
3. Secure your site
Another feature of many dynamic sites is the use of a secure section for things such as shopping carts or user registration. When tracking these areas, check the secure status of your pages. If you're seeing an error or a notice that some portions of the page are not secure, make sure you are using the secure version of the tracking code. Compare the standard versus the secure version:
Standard: script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
Secure: script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript">
For more information, take a look at this article in the troubleshooting section of the help center: How can I obtain tracking code for secure pages?
We want you to maximize the power of your site by using Analytics—and that includes successful integration of the tracking code without introducing errors or preventing you from perfecting the other code on your site. Properly installing the tracking code, carefully testing your site, and ensuring secure sites are tracked securely are some of the ways you can make Google Analytics work for you.
1. Check the tracking code
Correctly installed Google Analytics tracking code does not generate browser errors. If you're seeing them, first check that your tracking code is installed exactly as it appears in your Google Analytics profile setting. Learn how to find your tracking code in the help center article Where Can I Find My Tracking Code?
2. Test your page
Google Analytics uses JavaScript code that is designed not to interfere with other JavaScript on your website. That said, when an error occurs, browser error messages often reference the first script executed. On a site using our tracking code, that is usually the first script executed, which makes debugging confusing. When debugging JavaScript on a site tracked by Google Analytics, try commenting out or temporarily removing the tracking code until you can detect and correct the error. Once your code is bug-free, adding the tracking code back in should not cause any browser errors to occur.
3. Secure your site
Another feature of many dynamic sites is the use of a secure section for things such as shopping carts or user registration. When tracking these areas, check the secure status of your pages. If you're seeing an error or a notice that some portions of the page are not secure, make sure you are using the secure version of the tracking code. Compare the standard versus the secure version:
Standard: script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
Secure: script src="https://ssl.google-analytics.com/urchin.js" type="text/javascript">
We want you to maximize the power of your site by using Analytics—and that includes successful integration of the tracking code without introducing errors or preventing you from perfecting the other code on your site. Properly installing the tracking code, carefully testing your site, and ensuring secure sites are tracked securely are some of the ways you can make Google Analytics work for you.