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.
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.![]()
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:
(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:
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.




138 comments so far
Ezada Sinn said:
Thank you for this post. Really helping me.
Corinna said:
I am using WordPress and my Dashboard has an Appearance menu but then the options under it are Widgets | Extras | Colour Options | Typekit Fonts | Edit CSS. None of these seem to work to get able to post the code from Google Analytics. I tried adding a new text widget into the Andreas theme but it just showed the text of the Google code.
Kelly Rowles said:
Thank you so much for this. This is exactly what I needed, step-by-step instructions!
Michelle said:
Thank you so much for the easy instructions!
John Beech said:
I’m having difficulty in figuring out how to paste the code into my WordPress blog – I’m using Andreas09 as my theme. Any suggestions?
Many thanks
John
Andrew G. said:
Hi Ryan, I hope you’re still checking this. I have a wordpress blog running the Vigilance theme. I’ve tried copying both the new tracking code and the legacy tracking code into a sidebar text widget.
No luck.
It’ll paste, and then on saving, it’ll delete all the ‘code’ parts of the text rendering it useless.
Any suggestions?
Mel Ristau said:
Adding to the “Thanks” for these instructions.
I’m having a problem mentioned in the discussion but not finding a solution . . . My footer.php does not seem to have a body. Begins:
“”
Advice?
Thanks!
Sarah said:
Thanks for the great instructions!
Tara Nemeth said:
Thank you so much Ryan! I am absolutely not a programmer and these instructions were straightforward and extremely easy to follow. The humor made the article actually entertaining – and will have me come back to your site for future technical help. Thank you so much!
Jenny said:
I don’t see footer.php. I’m using this theme: Ambiru by Phu Ly. Can you please suggest how else to do it?
Thank you!
kiwiflossnz said:
Brilliant clear instructions – thank you. Being a newbie to programming my own wordpress blog, this was easy to follow. Your site will definitely be bookmarked. Now to work out how to make my gravatar appear in the tab at the top of the page.
Sarah Seitz said:
Hello, I login to my WordPress blog at http://www.wordpress.COM, rather than http://www.wordpress.ORG. I’ve read all over the internet that if you’re using a .com wordpress account, then you can’t use Analytics. My blog is NOT self-hosted (it’s hosted through wordpress, domain is through GoDaddy). I do not have the option to edit my template and when I tried the other option of pasting the code into a Text Widget, the text shows up on the blog, which I don’t like. Is there a way to make it hidden? Please help!
Jared, Skelton said:
I am not able to figure out where to place my analytics code. I was able to do it in blogger easily but haven’t figured it out with word press yet.
Thanks,
Jared
Tracy K said:
Hello, I am using WP theme Blass and I can’t find a body tag in my footer.php. Can you help? I’d thought I’d updated with the UA code, but analytics is only tracking the old archived site.
Thanks much for your help!
Morgan said:
Is anyone familiar with the Ultimate Google Analytics plugin for wordpress? Does anyone know if it works or how long it takes for google analytics to recognize that you have added the correct code? Thanks.
lisa olausson said:
I have the exact same problem as Corinna mentioned. Can you please help me how to find the place where i should put my code? I managed to do it on blogger but not wordpress.
Thanks Lisa.
Lisa Olausson said:
Hello!
I have the exact same problem as Corinna mentioned earlier and I tried the text widget thing too. I really don’t know where I should paste my code. I hope you can tell me where I can put my code.
Thanks a lot, Lisa.