I have compiled a list of tips and helpful hints for anyone who needs to add Google Analytics code for your WordPress blog.  Some of these tips were provided to me by my blog mentor Damien Riley especially about the WP-HEFO plugin.  I have been troubleshooting my Google Analytics for several days now, I originally had it working and noticed for the past 2 days I had 0 traffic at all, when all my other blog stats have shown a fair amount of unique visitors.  Between 70 and 120 visitors per day was my average at this point.  I spent all of today troubleshooting and learned the hard way:

Don’t mess with your footer.php page included with your theme, they hide some custom stuff in there that will break things if you try to tweak or replace the file.  Especially if it is a compressed php where it looks like garbled text.

Don’t accidentally have Google Analytics code in more than one section on your side, always view Source and make sure you don’t see 2 GA code snippets on same html page, if you do, this will definately break reporting to Google Analytics.

With that in mind I wrote these simple instructions anyone can follow to add Google Analytics to their blog, read on.

  • Pre-requisites:
  1. Make sure you are only using your theme’s default footer.php file, if you edited it, deleted it and swapped a new one, you may have problems like I did.
  2. Make sure you have no google analytics code or widgets installed, if you have duplicate google analytics code then it will not report your site stats to google.
  3. Download and install the “WP-HEFO” plugin
  • Configuring Google Analytics on WordPress Blog
  1. First you have to create a Google Analytics account, log into http://www.google.com/analytics and create an account.
  2. After you create an account, link your blog.
  3. After you enter the information and register your blog click on Edit under the settings for your blog
  4. Then click on “Check Status” on top right
  5. You should see instructions for adding trackin code (ga.js)

This code should look like this below:  (Note, your getTracker(“UA-*) will actually be your unique identifier.)
<script type=”text/javascript”>
var gaJsHost = ((“https:” == document.location.protocol) ? “https://ssl.” : “http://www.”);
document.write(unescape(“%3Cscript src='” + gaJsHost + “google-analytics.com/ga.js’ type=’text/javascript’%3E%3C/script%3E”));
</script>
<script type=”text/javascript”>
var pageTracker = _gat._getTracker(“UA-xxxxxxx-x”);
pageTracker._trackPageview();
</script>

  • Adding Google Analytics code to your blog with the WF-HEFO Plugin
  1. Keep the GA code handy from the previous step
  2. Open web page up and open up your wordpress blog
  3. Click on Design -> Header & Footer
  4. In the Footer: Section cut/paste your full Google Analytics code.
  5. Click Update
  • Validation of your Google Analytics Code
  1. To make sure your Google Analytics code is working right on your blog I found an exceptional website called EpikOne’s SiteScan
  2. This site for free will scan your website or blog and analyze ever page to check for the Google Analytics Plug-In.
  3. This site found and scanned all my pages and confirmed my Google Analytics was working, it provides a great report summmary:

Screenshot of SiteScanGA Summary:
sitescanga

  • In Summary:

With the WP-HEFO plugin by Kaloyan K. Tsvetkov and the www.SiteScanGA.com I was able to get Google Analytics up and working properly with ease.

With these easy steps I was able to get Google Analytics working and reporting correctly for my website.  If you have not setup google analytics for your blog and have wanted to go ahead and follow my instructions.  Please let me know how well they work for you, and/or if you think I need to amend some steps.

Justin Germino
Working in the IT Industry for over 17 years starting with OS, Networking and then moving into web based technologies including authentication and online security. Dragon Blogger has unique insights and opinions to how the internet and web technology works. An Avid movie fan, video game fan and fan of trying anything and everything new.
Justin Germino

@dragonblogger

https://t.co/iWP6afuOc9 is a technology, gadget, software and video game site that features articles, reviews and giveaways.
Thanks for watching Red Dead Online w/Nate and Justin! I WILL NOT GET BANNED THIS TIME! see you on the next stream.… https://t.co/1DdkvfuK7p - 4 hours ago
Justin Germino