If you’ve been blogging for longer than a few months, you’ve probably heard of the ever so popular site analytics program, Google Analytics.
It allows blog owners to do such things as:
- Discover how your site visitors found your blog
- View how many visitors your blog receives each day
- View areas on your blog where people have clicked
- . . . and a ton more.
If you blog, it’s inevitable that you are going to try Google Analytics at some point. It really is a great analytics program; however, I must admit that it can seem quite complex at times and if you’re new to the program and you might feel a bit intimidated. In the near future I’ll try to post some examples on how to use the program.
When it comes to plugging Google Analytics into your blog, you have a couple of options available to you.
- Download and use a plugin . . . or
- Copy and paste code into your blog’s footer file
Why I don’t like plugins
Simply put, plugins slow down the load time of your website and also pose security risks which could leave your blog open to intruders. Even if the plugin is secure today, it might not be when a newer version of WordPress is released or if the plugin author abandons the program and stops issuing updates.
In my opinion, the best way (and just as easy) to install this is to simply copy and paste Google’s supplied code into your theme’s footer file. That’s it, no plugin, done and move on.
Step 1: Sign up for a new Google Analytics account.

Step 2: Copy the JavaScript code.
During the sign up process you’ll be asked things like your name, email address, etc. At some point, you’ll come to a page that looks like the image seen below. You will will need to copy this code and paste it into your blog.

As a side note, even if you used a plugin to install Google Analytics, you would still need to copy and paste this code at some point; so plugins don’t necessarily make things any easier.
Step 3: Pasting the code into your footer.php file
At this point, log into your WordPress blog and navigate to your theme’s editor by going to Dashboard -> Appearance –> Editor.

Then on the right you should see a list of your theme’s files. Click on the Footer.php file.

Paste the code you copied from Google Analytics just above the ending </body> tag.

Click Update File

And that’s it. No plugins and no worries about updates.
To view your site’s statistics now, log into your Google Analytics account and view your stats. It may take a day or so to start receiving your traffic stats, so if you don’t see it right away, just be patient.







November 3rd, 2009 at 8:54 am
your instruction is very very helpfull and easy
November 3rd, 2009 at 6:51 pm
Hi fazal, I’m glad you found it useful. Thank you for taking the time to let me know you stopped by. It’s always nice to see a new face/name around here.
Don’t forget to add your IP address to the Google Analytics Filter so you don’t record your own visits.
November 12th, 2009 at 1:02 pm
Thank you for the fabulous and SIMPLE explanation of how to get google analytics installed onto my wordpress website without using a plugin. I tried numerous plugins and every one of them gave me the same problems and issues. I followed your instructions and did it correctly myself in about 5 minutes.
I like the old KISS method – keep it simple stupid. forget plugins, they all stink, and so do their ‘newsgroup forum’ style support.
Much appreciated!!!!!
November 12th, 2009 at 9:18 pm
Hi Dan. Thanks for the comment and I’m happy you found the article useful. It really is just as easy as installing a plugin, isn’t it.
I love the KISS method, in just about everything!
January 2nd, 2010 at 3:05 am
Hi John,
Why that is not Save File or Update file button in the Footer (footer.php) platform ? I even change the file attributes but still unable to save the tracking code. Please advice.
Thanks
iris chan
January 2nd, 2010 at 5:37 am
Hi iris, that’s odd, you should be able to edit the footer.php file just fine. The only thing I can think of is your theme is blocking it somehow.
Are you using your own self-hosted WordPress blog, opposed to having a free one on WordPress.com?
If so, log into your web hosting file manager and navigate to your /wp-content/themes/your-theme-folder
You should then see the footer.php file in there. Use your control panel’s file editor to edit the footer.php file by clicking a check mark next to the file and then click “Edit” up at the top.
Then paste the code inside the file as I show in the tutorial, save, and close.
February 15th, 2010 at 8:05 pm
Do you have to install the code on each page of your blog, or only once on the appearance/editor/footer? You didn’t say.
Thanks for the great info!
Gary
February 15th, 2010 at 9:29 pm
Hi Gary. Just once in the footer.php file will do just fine.
My pleasure and thanks for watching.
April 5th, 2010 at 8:13 am
John,
This was very helpful! Thank you so much for directing me here and for actually having this post. I love video tutorials. They make things much easier for me to actually see what you are talking about. Just reading stuff is confusing at times. I’m a visual learner!
May 15th, 2010 at 6:54 am
The problem with your method is it doesn’t have the functionality which GA plugins provide. The most important feature is not logging Dashboard visits and admin visits.
To make this article very useful, you could write a simple piece of code which detects if the user is the blog owner (logged in), if so, that person isn’t tracked.
I have something simple I wrote myself, as I don’t like plugins either, if you would like it, just let me know.
Henry.
July 5th, 2010 at 6:23 am
Thanks for the tutorial. Your website is a goldmine of very useful information.
Will visit again.
Cheers.
July 6th, 2010 at 7:38 am
Hi Greg. Thanks, that’s nice to hear. We’ll see you soon.
July 8th, 2010 at 11:28 am
Hi, John,
I did what you said and added the new (asynchronous) code to the footer file, and it works fine for all my blog’s internal pages. However for some reason the blog homepage still is still showing the ga.js code.
Any idea why that might be? (I had some other people working on my site prior to this, so that may be part of it…)
-Jeff
July 8th, 2010 at 2:15 pm
Hi Jeff,
That’s odd. The only thing I can think of is that your index page uses a different footer, maybe? You can try adding the code also to your Main Index page… the index.php file.
Other than that, I couldn’t be sure without really getting in a toying with it. If it doesn’t work for you, the plugin might be the better option for you.
August 27th, 2010 at 2:44 am
Excellent tutorial. I don’t use google analytics, but I use the same method to place the tracker code of the software I do use.
December 19th, 2010 at 2:33 pm
There is some solid information in this post. I am in love with your blog so far. I’ve added the feed to my Google Reader RSS subscriptions and will give you a mentioning over at my blog. I did have an issue with how fast this post loaded. Might be an issue to check out.
February 27th, 2011 at 5:35 am
Hi John
My footer.php doesn’t contain a closing body tag.
It ends with a php function.
Presumably I just paste the Google Analytics code after the end of the info in the footer.php.
February 27th, 2011 at 10:43 am
Hi Keith.
Themes these days are starting to get a lot more complicated code-wise in order to make it seem easier for users. While this is great for newbies, as you can imagine it makes it hard sometimes doing tutorials.
If it’s working for you, great, you’re done. If not, here’s what I’d do. Either:
A) Try putting the code in your header.php file just after the body tag
B) Contact your theme owner and ask them where you can put the code.
A) should work just fine though.
February 27th, 2011 at 11:16 am
“B) Contact your theme owner and ask them where you can put the code.”
Sounds good to me.
Cheers John
April 24th, 2011 at 2:37 pm
For most of the WordPress sites I design I implement this basic Google Analytics function into functions.php to keep things lightweight and not dependent on plugins. The only extra feature added to Google Analytics is 404 error tracking, which I always add.
April 24th, 2011 at 7:43 pm
Hi Kevin.
Out of curiosity, what’s the difference by putting the code in the functions.php file?
April 28th, 2011 at 3:55 am
It Allows usage of custom variables in Google Analytics to track meta data on pages. Thanks for your support will try soon.
May 6th, 2011 at 10:45 am
This was a great article! Very easy to follow (esp. for technical illiterate folk like me!)
I had installed google analytics on my WP account the wrong way and couldn’t for the life of me figure out why it wasn’t working! I’m excited to see if this fixes the problem!
Thank you!
May 6th, 2011 at 7:16 pm
Hi Jennifer. That’s awesome. I’m glad it worked and you’re all set up. Thanks for leaving a nice comment.