How to Add Google Analytics to WordPress
Google Analytics is still the most used traffic analysis tool on the planet, although it seems a little bit old and slow for these times (it loads at a slow speed and shows the actual data few hours after any events occur on your website … ). WordPress & Google Analytics can work well together if you do it right.
Right now I’m using a plugin to add google analytics to my website, but there are few other ways to do that, depending on your imagination :).
First, let’s talk a little about this plugin. You can download it for free right here: Download Google Analytics for WordPress
Next, upload it to your “wp-content/plugins” folder and activate it from your plugins page in wp-admin. Once this plugin is active, you will have a new button in your settings sub-menu. Click on it and you’ll see this screen:

Here you can paste your google analytics code. Please note that this plugin works with the old version of GA as I marked with red in the screenshot (I hope in the near future we’ll have a version that will support the latest script from google). Hit update options and you’re done.
Another thing, if you’re logged in, this plugin won’t show the code in your page, so if you want to check it’s there, you need to logout first.
A second option would be to edit the theme files. This is good and bad at the same time. Good because you don’t have to get stuck with uploading plugins and so on, and it’s bad because it won’t work once you update your theme (or switch to another one). So it’s up to you if you use this method or not.
Here’s how to do this: first, you have to know what files from a WordPress theme are used always. These files are the header and the footer (the others might be used or not while user navigates on your website). Therefore, you may put the google analytics code inside one of those 2 files. I recommend editing the footer.php file because google instructions say that you have to place their code before the </body> tag. We’ll do so.
To edit your footer.php file, go to “Design” \ “Theme editor” and select “footer.php” from the right column. Once it’s loaded in the textarea, paste your code before the </body> tag, just like in the image below and hit the “Update file” button.

That’s it. You have installed Google Analytics on your WordPress Blog.
- Peter
(You can find an update for this post here)
Tagged with: google analytics • how to • wordpress
Filed under: General • Wordpress How To
Like this post? Subscribe to my RSS feed and get loads more!





Simply copy paste the code into the footer file of your theme
Hey,
I am new to wordpress.. and I sort of don’t know where to find the “wp-content/plugins” folder…
Neither can I find the Deisgn/Theme option ANYWHERE..
please help!
You need to host your own wordpress, not use wordpress.com.
in google analytics webpage , thay are saying paste this code on every page which you want to track..
is it enough just to edit footer.php?
yes it is
Hi Peter, I’ve tried this and it says “The requested theme does not exist.”
Help? Thanks!
What exactly did you try?
Sorry, I tried adding the analytics code to the footer by going to Appearance – Editor – Theme Files – Footer. When I update the file it gives me the “requested theme does not exist” message.
It is for our company website that we had designed. I’m not sure if it is an issue the designer should be looking at.
You could try reuploading the theme then using google analytics plugin. You can find it at http://www.googleanalyticsplugin.com
Thanks Peter.
Hi – I am also new to wordpress and I’m also not great with computers…I have honestly no clue how to do this, I’ve tried and searched but can’t find anywhere to put this code. I can also only find headers not footers. And step by step help would be greatly appreciated as I honestly have no clue what to do! Thanks.
I’m not sure wordpress.com gives you the possibility to edit your theme. I was talking about self hosted blogs here, which, by the way, are muuuch better.
Cheers
I have followed you directions but it says its not installed, does that take hours to update also?
Yes, it takes a while for google to update stats.
Hi, nice information about google analytic to paste code in wordpress blog. I used plugin for analytics it’s ok but but I don’t know how where to paste adsense link analytical code in wordpress blog… can you explain
You may wanna check this out: http://www.wordpressmanager.com/wpcodeman
Hi Peter,
I have followed every thing to the T, But I cant upload the download in to my word press via plug-ins. Am I doing something wrong? File is saved on my desktop, I upload it but it tells me it incomplete!!! Any Ideas???
Thanks
Bruce
Try FTP. It may be something wrong with your browser or something.
Hi Peter, thank you so much for information on where to paste the code I had previously pasted it in Index.php obviously it did not work am now waiting for Google to update it can take up to several hours I understand maybe even 24 hours. Anyway thanks for the help!
Joseph D
New Hampshire