SearchForecast Marketplace

Adding Google Analytics to your WordPress Blog

Posted by: dragonblogger  //  Category: Internet, blogging

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.

Related posts:

  1. Enhance Your WordPress Blog 404 Page One of the highest recommendations I have is to make sure when a user hits a dead page on your...
  2. Dragon Blogger’s Favorite Google Adsense Plug-In for WordPress I have tried numerous Google Adsense Plug-ins for WordPress downloaded from WordPress Plugin site and have had limited success. Most...
  3. Adding A BlogNetAward Widget To Your WordPress Blog My friends over at BlogNetAwards enjoyed my “How to vote” video demonstration and asked that I create another demonstration showing...
  4. Playing With Google Analytics For Your Blog I looking at my blog traffic from October 1st through October 27th 2008.  I seem to have plateaued in visitors...
  5. Instant Access To Analytics from WordPress I saw in WebSite Magazine an article about MailChimp’s Analytic 360 plug-in for WordPress and I decided to install it,...


If you enjoyed this post, subscribe to DragonBlogger.com
via FaceBook, Twitter, RSS or Email
or
Enter your email and subscribe now!
Email:

Written by dragonblogger (1110 Articles Published)

Working in the IT Industry for over 10 years and specializing in web based technologies. 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.

Follow dragonblogger on Twitter @dragonblogger

Tags: , , , , , , , , , , , , , , , , , , ,

16 Responses to “Adding Google Analytics to your WordPress Blog”

  1. Damien (62 comments) Says:

    This is excellent. I get people asking me all the time about how to install and use Google Analytics. You’ve really stepped up and created a top shelf tutorial. Thank you. I’ve bookmarked this post for future reference and recommendation to folks. Thank you also for your kind mention.

    [Reply]

  2. dragonblogger (1957 comments) Says:

    Thank you and the best part is, IT WORKS. I finally saw my google analytics stats this morning after two days of big fat 0′s.

    [Reply]

  3. Dani (12 comments) Says:

    So far, the code is working in this blog and I’m waiting until tomorrow to see what it spits out at me. As for my mom blog, however, for some reason it keeps on saying that the code isn’t even there when I know I put it in the footer.php on that… I’ll check that one later, though, and see if it’s just taking a little bit longer than normal to add in.

    [Reply]

  4. Dani (12 comments) Says:

    Just letting you know, it now works on the blog I’m linking this comment from! :)

    [Reply]

  5. Eric Lightbody (1 comments) Says:

    Friggen awesome! I have been looking for a while on how to insert custom analytics js with various plugins. The wp-hefo plugin is phenomenal. Thanks a ton!

    [Reply]

    dragonblogger (1957 comments) Reply:

    This is my favorite analytics plug-in for wordpress by far, thanks for finding it.

    [Reply]

  6. Sandesh (5 comments) Says:

    I had problem earlier with Google analytics earlier. But rectified it later on. Your post would be very helpful for people have problems with google analytics code insertion.

    [Reply]

  7. jan geronimo (19 comments) Says:

    Very helpful tutorial, Justin. You’ve the complete package, including a website to check if the added GA code is actually working. Nice touch.

    [Reply]

  8. Alan from Glass Pipes (13 comments) Says:

    Thanks for the footer tip, I managed to get Analytics up and running a few days ago and it seems to be working ok so far.

    [Reply]

  9. Karen from Blazing Minds (55 comments) Says:

    Luckily my blog theme allows me to add HTML via some settings, so adding the Google Analytics was quite easy, but this is some great information and well written for newbies and those stuck with adding the code to their blogs ;)
    Karen @ Blazing Minds´s last blog ..Weekly Round Up – iTunes, Michael Jackson, Monkey Dust My ComLuv Profile

    [Reply]

    dragonblogger (1957 comments) Reply:

    Thank you, that was my intention was to show people who don’t navigate around the php files how to do it.

    [Reply]

  10. Dennis Edell (91 comments) Says:

    Excellent keeper DB, I should be adding GA, when I complete my move.
    Dennis Edell´s last blog ..Are You Thankful For Your Blogging Community? My ComLuv Profile

    [Reply]

  11. Cheap Lcd Plasma TV (3 comments) Says:

    Thanks for the post on adding google analytics to wordpress blogs. Its straight forward and informative. Word on the street is that google analytics opens a can of exposure worms for those who work affiliate websites. How true is that?

    [Reply]

  12. chakkravarthi from seo your blog (1 comments) Says:

    that’s an useful plugin to ease your analytics installation process for sure.
    chakkravarthi@seo your blog´s last blog ..5 Tips On How To Decide On Your Blog’s Niche My ComLuv Profile

    [Reply]

  13. Kaloyan K. Tsvetkov (1 comments) Says:

    Thanks for all the good words and I am really glad that you find this little WordPress plugin useful.

    [Reply]

    dragonblogger (1957 comments) Reply:

    No problem, thanks for visiting and reading it.

    [Reply]

Leave a Reply

CommentLuv Enabled

This site uses KeywordLuv. Enter YourName@YourKeywords in the Name field to take advantage.

Comments links could be nofollow free.