Tag Archives: Wordpress

WordPress Google Analytics

Problems adding Google Analytics to wordpress blog. You might be missing as many as 95% of your visits and pageviews! Here is how to add Google Analytics to a wordpress installation correctly without using a plugin.

Add Google Analytics to WordPress blog

A full guide on how to add Analytics to WordPress then is:

  • Login to your Google Analytics service and get the tracking code.
  • Login to your WordPress admin panel at whateveryourblogdomainis.com/wp-admin.
  • Go to the Appearance menu option and select Wdigets.
  • Drag across a Text widget into the primary widget area.
  • Open the text area by tapping the arrow beside it and paste your Google analytics code in there.
  • Your Google Analytics code will now function correctly!

You can also add the Google Analytics code directly into your WordPress theme footer. I do not recommend this because if you must remember your changes and repeat them if you want to change WordPress themes.

Another way is to use a Google Analytics plugin. I do not recommend this because it means tracking and checking updates to the plugin. The method I have outlined above is what I personally use (you can check the source on this site to see for yourself). The method above is also what I recommend to all my clients and it loads as part of the WordPress menu system.

Installing Google Analytics on WordPress blog

At first, I had copied the Google Analytics code exactly as given from another random website. This did not work in WordPress because wordpress did not recognise the end of the first line, which is Googles comment, as an end comment. This is the exclamation mark, followed by two dashes and a greater than symbol. Because of this comment extending, WordPress viewed the entire Google Analytics code I pasted in as part of an extended comment and did not process it as script.

To quickly fix my tracking code on wordpress, I removed that first line that says Google Analytics inside two triangle signs. It was just a comment anyway and didn’t affect tracking itself.

I didn’t know that my google analytics code was not working on my WordPress blog until I added another analytics mechanism. Then after fixing the Google analytics code my visitors jumped by 1000’s! Which just shows how bad the commenting out was affecting things.

Anyway, check your Google analytics code and make sure it’s working!