On Line Casinos Canadian Currency Canadian Online Slot Gaming Best Canadian Online Gambling Site Play Cleopatra Online In Canada Canadian Real Slots Online Online Casino Bonus Canada Brand New Canadian Online Casinos Canadian On-line Casino That Uses Paypal Canadain Flash Casinos Casinos En Canada Canada Online Casino Coupon Code Blackjack Paypal Canada Canadian Bonus Casino Best Casino Accepting Canadian Online Canadian Blackjack Online Casino For Canadian Player Real Money Online Casino For Canadians Canada Slots Casino Slots Online Canada Best Canadian Online Casino Forum Canadian Casinos For Mac Gambling Age Canada Online Canadian Money Casinos Online Canadian Casinos Online Casinos That Except Canadian Money Good Online Canadian Casino Casino Sign Up Bonus Canada All Casino In Canada Real Gambling Online In Canada Online Gambling Slot Machines Canada Top 10 Online Canada Casino Roulette Online Casino Cleopatra Slot Canada Canada Casino Games Canadian Craps Online Casino Age Canada Best Casinos In Canada Canadian Online Casinos Top Ten New Canadian Casino The Best Canada Online Casinos Online Top Canadian Casinos Canadas Best Slots Online Canadian Online Casino Mac Canadian Only Online Casinos Top Online Canadian Casino Best Online Casino For Canadian Canadian Slot Machines Games Casino With Paypal For Canada Best Online Canada Casinos Best Online Casinos For Mac, Canada Play Canadian Online Slots Canada Slot Machines Slot Machine Games Canada Best Canadian Online Slots Canada Online Slots Real Money Credit Cards Gambling Canada Online Casinos Accept Canadian Players Canada Online Igt Casino Casino Canada Downloads Play Online Slots For Mac In Canada Canadian Paypal Deposits Casino Canadian Online Gambling Top Ten Canadian Online Casinos Top Canadian Casinos Canadian Express Casino Casino In Canada Mac Canada Online Casino Canadian Online Casino For Mac The Best Online Casino For Canadians Best Canadian Casino Canada Casino With Paypal Canada Casino Online Slots Online Slot Games Canada Best Canada Casinos Download Casinos In Canada Canadian Online Bonus Slots Online Casinos For Canadians Casino For Canadians Canadian Slots Online Play For Money Canada Online Canadian Slot Play Canadian Online Casino Canada Money Casino Games For Mac Canadian Mac Slot Downloads Online Casino Instant Deposit Canada Canadian Players Online Casino Slot Casino Canada 10 Dollar Canadian Casino Newest Casino In Canada Canadian Games For Money Canada Gambling Age Canadian Casino Slots Canadian Casino Games Playing The Slots Online In Canada Slots Canadian Canadian Best Bonus Casinos Canadian Slot Machine Games Canadian Video Slots Online Slots For Real Money In Canada Casino Canadian Money

How to Install Google Analytics on Your WordPress Blog

As Theme Playground approaches the end of its first week online I decided it would be a good idea to set up Google Analytics to track the stats. And it seems only fitting that we take this opportunity to, together, walk through the steps of setting up Google Analytics on a WordPress blog.

Google Ana-what?

Google Analytics is the mega-giant Google’s version of stat-tracking. They are also, arguably, the best available.

Google Analytics is a free service offered by Google that generates detailed statistics about the visitors to a website…Most important, a webmaster can define and track conversions, or goals. Goals might include sales, lead generation, viewing a specific page, or downloading a particular file. By using this tool, marketers can determine which ads are performing, and which are not, as well as find unexpected sources of quality visitors.

Just to give a taste of what we’re talking about.

I have, honestly, never used Google Analytics before. In the past I’ve tried other stats tracking plugins for WordPress (not to mention WordPress.com’s official stats plugin earlier this week) but nothing ever worked out. So, on to the big boys.

Let’s install it already.

First Things First

Do you have a Google account of some sort? You will need one. That’s okay if you don’t, you can grab one during the process.

Hit up the following link: http://www.google.com/analytics

Now is the time to sign in. Look to the box on the right. If you don’t have a Google account, you will be prompted to sign up now. Do it.

Google Analytics - Step 1 Small

I’ve signed in with my info above. And don’t both trying to get in, it’s hopeless :) .

If this is your first time stepping into Google Analytics (which it probably is) then you’ll see a screen prompting you to enter the information for the website you are wanting to track. If you don’t have a website…well…um…why set up an analytics account?

Seriously. Why bother?

So assuming you have a website, throw the address in there with all the information it asks for.Google Analytics - Step 2 Big

Next it will want your name (no cheating) and number, same as any first date would expect. Again, throw all the info they want into the boxes and hit Next.

Finally, make the Google lawyers happy by agreeing to their terms of service. I would tell you what is written there, but I have no idea. Who actually reads that stuff anyway?

Create New Account. Done and done.

Well, not quite.

Plugging into WordPress

A brand new screen should be showing, prompting you to drop a set of code into the footer of your website pages. It should look something like this:

Google Analytics - Step 3 Small

(Click above for a larger view)

This is where having a WordPress blog makes life easier. Google wants to converse with your website (just like you’ve asked it to) but needs a certain Javascript code to be at the bottom of every page of your web site. If your site is static, this can be a pain, or at least an annoyance. But since we’re using WordPress, and everything is dynamic, we only have to copy and paste once.

Log into your dashboard (preferably in a new window) and browse to Presentation > Theme Editor > footer.php.

Note: This is assuming that you are using a fairly standard WordPress theme which uses footer.php as the final template of a page. If this is not how your blog is set up and you can’t figure out where to go, post a question in the comments to this post.

Take your Google Analytics code and paste it into your footer.php file in WordPress. It shouldn’t be all that important where the file goes as long as it comes before the ending body tag. In other words, just put your GA code where I indicate in the following screen:

Google Analytics Step 4 Small

Of course hit Update File. As far as WordPress activity goes, you’re set! Nice work.

Check Status and Analytic Stats

A nice big button on your Google Analytics homepage should say Check Status. You’ll want to click that so Google can start communicating with your website.

Now all you have to do is bookmark Google Analytics and keep an eye out. Of course it will take a few days before any stats start showing up. Believe me, I know. The stats for this site are still in the collection stage.

Whatever you do, don’t get into the habit of checking your stats every 5 minutes or else…oh, hey, sorry I have to go…yeah, you know.

Note: Having problems? Post a comment below and I’ll see what I can do.


Did you enjoy this post? Then it might be worth your time to subscribe via RSS using your Feedreader or, if you prefer, via email.

About the Author: Ryan Imel

My name is Ryan Imel, and I’m a full time freelance web developer. I work a lot with WordPress, but am comfortable with other systems too.

135 comments so far

  1. Scott said:

    Hello and thank you for the great instructions. The comments are a worthy read as well! I installed the google analytics tracking code to my footer.php at my website, but I am now interested in the code to avoid tracking admin hits on the site. This would really help to make my stat tracking data more reliable. I know I have seen that code floating around somewhere… but where?

    • nicole said:

      You should be able to set up a filter in GA to exclude any hits from your IP address.

  2. ANN QUIAZON said:

    i’m fairly new to blogging and i’m at a lost among all the codes.

    i was trying to paste the google analytic codes to the footer.php just like you said but changes can only be made if i make the page rewritable. When I checked the codex blah blah i really think its such a hassle,i might get lost the more,please help.

    is there a way to do it without all the hassles?

  3. SteveB said:

    I like to track clicks on links on the page, I don’t think you will get that pasting to footer directly. Also, to Scott above.. To stop admin hits in Google Analytics, create a filter (in analytics) that will ignore your ip.

    Steve

  4. Tizmanian said:

    Perfect instructions! Thanks dude.

  5. Ronin said:

    Im new to GA and need to a reference for installing it on WP.

    Great and thanks for posting.

  6. Hi thanks for the step by step method of putting this to work

    Thanks again

    Danny

  7. Hi Ryan thank you for this advise. But I just updated the Word Press Blog and this is the latest, I think 2.71 , would your way of doing code installation work for the latest version?
    thanks
    Michael.

    • Ryan Imel said:

      Hey Michael, thanks for reading. Despite the update in WP since this was written, it should absolutely work with 2.7. I’ve used a method like this for every version of WordPress since 2.0.

      You can also try putting the Analytics code into a sidebar widget, which might be slightly easier than digging into the theme.

  8. Joanne said:

    Hi Ryan,
    We have a wordpress blog for our business. The blog stats are really limited and I can’t really get the kind of tracking info I need. I saw your article about how to install Google analytics on your wordpress blog and thought I’d try it, but I’m not seeing a Theme Editor>footer.php option. This is the link to our blog:
    http://soundviewsummary.wordpress.com/
    I’m not sure if the version we’re using even has editing area this available. Hope you can help! Thanks.

  9. Carlo Duncan said:

    Dear Ryan,

    I am unable to find Presentation > Theme Editor > footer.php in my theme which is Vigilance. Can you help me, or must I change theme in order to apply GAnalytics?

    Thanks
    Carlo
    awakr.wordpress.com

  10. Pat Alb said:

    Hey Ryan, I thought I was saved from the tech world when I saw this nice info but I think I have a diff setup. I followed your instructions and went to dashboard, appearance, themes & editor and landed on Stylesheet (sheet,css).
    Do you have any suggestions how I can add the google analytics and adsense codes into my wordpress? Thanks in advance, i think you’ll do very well on this site!! G.L. – Pat

  11. Scott Summit said:

    Ryan, thank you for taking out the time to create this tutorial.

    We are using WordPress 2.7.1 and our blog lives on a subdomain.

    Right now the Google Analytics and Quantcast code is on the main page of the blog. If you click through to the URL with the entire post, the tracking codes are not included on the pages with the individual posts. Any help will be appreciated.

    Thank you for your time.

    • Ryan Imel said:

      Hey Scott, hope I can help. If you place the Analytics code into a new text widget that is on a sidebar that is on every page of your site, that should fix your problem.

      If that doesn’t sound right for you, then give me a ring on the contact form, and maybe getting some more specifics on your situation I can help better.

  12. Hi Ryan, great tutorial – I’m always on the lookout for WordPress sites.

    @Pat Alb – When you click on the Editor, the stylesheet is typically the first file you land on. Over on the right you should see a list of files, one of them should be your footer.php file. Click on that, paste in your code, and click “Update.”

    @Joanne – Log into WordPress and you should arrive on your Dashboard. Over on the left you should see a menu called “Appearance”, click that, then click “Editor”. From there, follow what I mentioned to Pat just above your comment.

    • Ryan Imel said:

      Hey John, thanks for helping out here. I’ve been meaning to update this tutorial with a screencast, but won’t have time for that until next week. Can’t ask for more than one commenter helping another, though :)

  13. We’re all here to help each other. I know what you mean about time – there’s never enough.

    • Ryan Imel said:

      Definitely. Just let me know if there is anything I can do for you, John!

  14. foodie said:

    Thanks for the tut dude. It went off without a hitch except for the difference in menu options with the new wordpress version. Fortunately I’m familiar enough with the interface that I figured it out before seeing the comments. Now to wait 24 hours and see if it worked…

    I really appreciate the time you took to post this.

  15. Steven Vilendrer said:

    Please help! I’m trying to install the analytics tracker but the website pages have no tag anywhere. I’m working with PHP code in Dreamweaver and trying to install this for my boss. Could someone please help? Thanks.

    • foodie said:

      Please be more specific, so we can help you.

  16. Steven Vilendrer said:

    that is no tag anywhere.

  17. Steven Vilendrer said:

    “body” tag, written with the arrow point out on each side and the slash before. this blog keeps cutting out code.

  18. Raul said:

    Thanks for the easy tutorial, unfortunately it’s not working for me. I’ve pasted the new google analytics code immediately about the in footer.php. I can see by “view source” that the code is there, but Google does not see my tracking as being installed.

    Any ideas, and thanks!

    • Raul said:

      Fixed…

      Well, I seem to have resolved it. Google provides this code:

      try {
      var pageTracker = _gat._getTracker(“whatever”);
      pageTracker._trackPageview();
      } catch(err) {}

      but in the help refers to the same code without the error trapping. I removed the try / catch bits and it’s hooked up now. Off to tell google, I guess.

  19. M Rahman said:

    Thank you so much . It is a very useful tips. But I just updated the Word Press Blog and this is the latest, I think 2.71 , would your way of doing code installation work for the latest version?I really appreciate the time you took to post this.

  20. tom benedek said:

    Hi:

    I am using chaostheory and cannot figure out how to add the google analytics to the footer. Thanks for you help.

    Tom

  21. tom benedek said:

    I am using Chaostheory theme and cannot figure out where to past the text from google analytics. On appearance-theme i cannot find footer!

    Thanks,

    Tom B.

    • Raul said:

      You could always grab the file from your server (SCP or FTP), edit it manually and restore it. Or, if your provider allows shell access, just manually edit on the server with, say nano (or if you are Linux guy, vi, but I’m not sure you would have asked in that case).

      Good luck.

  22. THAN YOU FOR THIS! This has been a problem for me and your instructions are great. This fixed the problem I was having getting my Google Analytics stats. Now I will finally be able to run my reports.
    Catherine

  23. yes you can also do like this

    Adding Google Analytics to WordPress blog (for newbies)

    http://codeforfuture.com/2009/03/13/adding-google-analytics-to-wordpress-blog-for-new-bies/

  24. Justyn said:

    I like your post about Google Analytics, but what was it about the official WordPress Stats plugin that “didn’t work”?

    I have been using it for about a year or two on my blog and hasn’t failed me yet, I’ve never seen the reason to switch.

    You said in regards to WordPress stats plugin “I would still suggest ditching the plugin because it isn’t locally hosted.” but isn’t Google Analytics hosted by Google, or is it run locally on your server?

  25. Bunny Smedley said:

    I have a WordPress blog, using the PressRow theme, and am trying to add Google Analytics. Your instructions look admirably simple, but when I browse to ‘presentation’ in my Dashboard I can’t find ‘theme editor’ anywhere.

    Sorry if this is a really silly question, but can you please help me figure out where the code goes, using PressRow (you gave it a good review so I assume it doesn’t somehow block Google Analytics?)

    Thanks!

  26. Sid said:

    Hey man thanx for the great advice.

    The thing is, I don’t have any theme editor in my dashboard. So ‘im wandering if the problem is my theme that doesn’t allow me to play in the editor. Do you have any suggestions??

    thank you very much

  27. Hey, i get this message on the bottom of my site

    T_CONSTANT_ENCAPSED_STRING in /home/content/j/a/b/jabaez02/html/wp-content/themes/german-newspaper/footer.php on line 60

    what the hell is it? How can i fix it?

    Thank you..

  28. Pat said:

    Thanks, very simple and easy to follow instructions. really helpful.

  29. Dan Irwin said:

    I am brand new to coding and wp. When I go to my footer.php template, there is no code…just hundreds of lines of gobbledy-gook running together (theme is travel 3). I added the code after this, then added:

    But GA is not seeing it. There is no other real code on the page, except <? at the top.

    Can you help?

  30. Topangadan said:

    My footer has no recognizable code…just hundreds of lines of gobbledy gook. No php anywhere to be seen. I added the code to the bottom of this, but it had no effect. GA is still looking for me.

    Any suggestions?

  31. @Dan Irwin – looks like you got it. I went to your site and can see the code at the bottom when I view your source code.

    @Topangadan – you appear to be the same person as Dan? See my reply to him above. ;)

  32. Apoc said:

    Really useful post. Thanks!

  33. ximi said:

    hi, ryan…
    I have put the script on my pages, it works. It’s a great tool frm google. I also installed Google Analytics Dashboard plugin into my wordpress. I have put correct email and password, but it doesn’t work. It can not “connect” to google.
    Do you have any idea?
    thanks

  34. Nail said:

    Thanks for the instructions, it really helped, additionally I would like to know if anyone can answer that: Is there a way to filter admin hits if I am not using static ip.

    Thanks.

  35. Nail
    Even though you’re on a dynamic IP, it probably will rarely change. Go ahead and set up Google Analytics to filter your IP and if your IP ever changes, just do a quick IP change.

    • Nail said:

      Hmm, maybe I should change my ip info in Google Analtyics, before I start working on my site each time.

      Thanks a lot.

    • Joel Ryan said:

      John, I’ve read your comments on Ryan Imei’s post concerning google analytics. You seem to be very knowledgeable. I am new to wordpress, and I am only dabbling to help a friend’s post. While trying to load GA, I only get an option to edit css. There is nothing to the right of it as mentioned. Every suggestion made in the post does not help me. Someone mentioned using a text box. Would that have to go on every page? Will the text show on the site? I’d like to install this as clean as possible but I’m having tremendous difficulty getting around the lack of a theme editor option. Could you please advise? What started as a favor is turning into a hassle.

  36. Sarah W said:

    So I followed the instructions and pasted the code in the footer php section right before the body text but when I hit update file the changes dont show up/remain in the code. The analytics setting page has a tracking unknown signal and the view source code on the blog doesnt reflect the new analytics code either. Did I do something wrong? I’ve tried several times now, is that just making it worse? Please help!

  37. Russ Wood said:

    Thanks for the guide, Ryan.

    I’ve put the analytics code into a text widget on my side bar and it seems to be doing the trick.

  38. Josh Rimer said:

    Awesome, thanks for making it so easy to add that to my new blog! :-)

  39. Richard said:

    Thanks for the detailed instructions. However, I am using the theme “Black Circle” and when I view footer.php there is just a series of numbers and letters ( basically cr*p) – when I select a classic theme from WP , the correct code can be identified. Any ideas ?

  40. jual rumah said:

    Hi Ryan, thank you for the useful tutorial. I forgot putting Google analytics code in my blog so it is not recorded in the analytics. But, unfortunately I don’t find the menu of Presentation. I use the version 2.7 Would you show me where it is ? Thank you again for the information you share.

  41. Elliott said:

    I’m using the Vigilance theme. When I go to the dashboard, I can’t seem to find the “footer.php” link to paste the code in.

    Can you help me?

  42. Hi Ryan thanks for the advice, I’m using Press Row on WordPress and I can’t find my footer.php. I tried adding a text widget with the code for Google Analytics, but it just showed up as code on preview. Any suggestions?

  43. Hans Haupt said:

    Thank you so much for creating this tutorial.

    Your post is easy to read and concise.

    With your tutorial, I was able to easily add the Google Analytic tracker to my blog.

  44. Howdy,

    Just wanted to drop you a line and thank you for a great post. Yes – it’s may not be the only one “out there” about how to add GA to a footer.php file – but it’s great that you’ve taken the time to write it – and even added screenshots to it.
    Hope you get lots of traffic from it as a result!
    Cheers,

    Guacira

  45. Grazina said:

    Hi from the Land Down Under
    Ryan thank you so much for easy to follow and clear instructions. Done in two minutes! :-)
    GA

  46. Thanks for this. I was following the directions from Goggle and they were telling me put it in the index.php file. Seems to work now that I stuck it in the footer. Thanks again. Good instructions.

  47. Paul said:

    That was great, I used this to install GA on my blog (swine flu haha). thanks!

  48. Hazel said:

    VERY helpful post, thanks for taking time to share ;)

  49. Nitin Pahuja said:

    Thanks for your useful post

  50. Shonda said:

    Thanks a ton for the easy to follow directions! I appreciate all of you open tech bloggers.

Add to this discussion

Required: We need to know who you are.

Required: Your email will not be published. This will also give your comment a gravatar. (What is a gravatar?)

Optional: This will make your name clickable.

Required: Kind of the point of this whole form, don’t you think?

Trackbacks/Pingbacks