Easy to follow tutorial how to insert or put Google analytics code in your wordpress blog theme file.
Google analytics is one of several ways to track your blog’s visitors, like, where they come from, which search engine brings you the most traffics, or which referral websites your visitors come from, and many more.
The most useful is you will know how many visitors you receive a day or some specific period of times. I added my blog to Google Analytics right after submitting my sites to search engines, like Google, Yahoo, Bing, and Ask. The result will usually show after a few days.
I have decided not to use any Google analytics plugins for this, because we can easily do it without plugin. Do remember, using too much plugins can slow down your page load, and sometimes buggy while upgrading your blog.
If you are using Thesis theme, it will be much easier, you just need to enter the code to tracking Thesis options.
So this is how i get Google Analytics code and paste it in my wordpress file or it will work for any html static websites too (I use twenty ten theme of wordpress 3 for this tutorial):
1.Β Go to this URL: https://www.google.com/analytics/reporting/login and sign in with your gmail account.
2. Click “sign up” button.
3. In “New Account Signup” type in:
-Website’s URL = www.yourwebsiteaddress.com
-Account Name = your web address by default, i left it as it is.
– Time zone country or territory = where you are at.
– Time Zone= Type in to suit your time.
Click “Continue”.
4. Next, type in your first, and last name, the country and click “Continue”.
5. Read the Terms and Conditions of Google Analytics, and after all ok,Β tick “Yes, I agree to the above terms and conditions. Then hit “Create New Account” button.
6. If we did all correct, the next step is you will see your tracking codes. Copy all of the codes, and Go to your wordpress dashboard admin page.
7. Click Appearance/Editor and look for footer.php.
I personally paste the code in footer of my wordpress theme file, not in </head> as it shown in Google analytics page. Most people paste it in footer, and i never had any problems with having the code in footer.
Open up this footer.php file, and paste the code right before this code: </body>
Click “Update File”.
Note: There are some theme files which provide you only to add the Google analytics ID, if your theme has this function, then just add theΒ GA ID which is displayed in your code too. (see image).
8. Back to Google analitycs page, the last step, is hit “save and finish” button.
9. You will see the website profiles tables, and see your wordpress blog’s URL too. After a few days, check to see the report by clicking “view report” link.
That’s how i copy and paste Google analytics code to my wordpress blog, did you do differently? π
Video Tutorial:
For folks who tend to work a lot on our themes, using a plug-in like Google Analytics for WordPress 4 is best. That way we can avoid tracking our visits while previewing our theme/blog changes.
@Udegbunam Chukwudi, Thanks for the suggestion.
WordPress 4? or is it the name for the plugin?
You’re welcome. The name of the plug-in is Google Analytics for WordPress 4
Hi,
An awesome blog with clear step by step directions to help showing how to put Google Analytics code and paste it in the wordpress file
with ease.
Thanks for the clear directions.
All The Best,
Patrick Lim
Hey there Patrick,
Thank you for the encouraging comment, and i am glad the tutorial was clear for you π
You have a great site, however you may want to fix the “I love the giveaway of the day” box, because the width is somehow bigger than your sidebar’s width.
Cheers Patrick.
Hi, I’m glad I’ve found your site because I was just wondering lately how to paste it without downloading the plugin in wordpress. I know it could result to some slow if I will install a lot of plugins. Well, this saves my time. Hope it will take effect soon.
Thank you for leaving a comment!
Glad it saved your time.
Hi,
Iβve recently started a blog, the information you provide on this site has helped me tremendously. Thank you for all of your time & work.
Great blog.And I just want to say thanx to you for awaring me
about the new and revised things about google.
Thanks, really helpful. Even though Google has made it more complex these days, I was still able to follow this really easily and get it working. Awesome.
hi , this is very helpful, really appreciating your attempt
Excellent – I was pulling my hair out how to get google analytics set up but you have made it really clear.
nice one
well i’m using thesis theme and headway + catalyst on my blogs and i do not need to edit any of the files
Hi Vivek,
Yes, if we use those premium themes, we won’t need to edit any files, but not every bloggers have premium themes π
I notice Twenty Ten is still loveable..
Thanks for your comment!
very helpful, just submitted analytics to my blog according to this. but still the status is “tracking not installed” hope that will be ok within few hours or days
Thank you so much. The best detailed information I have found. Most people just say paste it in footer file without stating which line. I’m new to wordpress.
Most Welcome, Alec!
Glad you found it easy to follow π
Thanks!
Thanks Kimi,
Finally someone who gave me an answer on what I was looking for. Well explained with the snapshot of the steps to follow. A picture is worth a thousand words. I am using the twenty ten Red Theme and couldn’t find anywhere even in the vague instructions given in theme settings on where it went. I have the site since last fall and haven’t been able to add the analytics because I had no clue where to put it (for that theme). Usually it’s easy to insert it and find the portion of the header but for the Red theme it looks complicated to find. I was, I guess stubborn and kept believeing in putting it in the header. But if it works just the same in the footer then “COOL”.
Thanks a lot…
Most welcome!
First blog clearly explaining step by step and not missing stuff. Thanks!
Hi Kimi —
I’ve paid for a .com domain through wordpress, and I guess that means it’s different from wordpress.org?
Anyway, I don’t have the same screens or settings as you guys: if I open a widget called footer, I put in a text box so I can enter HTML and then I paste my code, with the at the end.
However, I just get the garbled code showing up at the bottom of my webpage. I assume it’s not supposed to be like that. Any suggestions?
Thanks for the info that was dying to look for. π But have a query. After I pasted it in the footer as per your instruction, will the analytics be made of every page of my website or only home page? May be a silly query but I am a complete novice in this field, so would love to know. Thanks in advance!
Hi shreya,
I also embedded in my footer in this blog, it will be used in every page of your site π
It’s absolutely not a silly question, have a nice week
Kimi.
Hello….you posted this in July 2010 and it is still helping others…I found it very clear and precise……thanks
hal
Hi there,
Great tutorial, but I’m in the same boat as Alexander…sucks that WordPress doesn’t allow this if you are a .com. Balls. The garbled code that results in the footer doesn’t look clean so now what?
Hi Alisha,
Welcome to my blog, and yes, you are correct wordpress.com doesn’t allow the users using javascript, including adds and any affiliate links.
If you are serious into setting up a website or a blog, I would recommend directly getting a webhosting, I used this webhost to begin blogging with this site.
With this few advantages:
1. Cheap PRICE. Costs only 4 bucks a month, it’s like a bottle of coke a month, and reliable. I know you will read some other reviews, but trust me, I used it for years and don’t have a complain or issues. I also use other hostings but they are more expensive so not very ideal to start your own blog unless you have a budget, but they also have same features.
2. Free one domain name, other cost you extra for a domain name.
3. You can monetize your blog for later use, or basically you have a full control of your site, no need to be worried to have hassles transfering or migrating your big blog once it is big.
With your own webhosting, you can then install wordpress with this quick clear video: https://www.wpvidz.com/wordpress-versions/
And you can add any plugins, themes, and any codes you prefer.
I hope this helps
Kimi.
HOW DID YOU FIX THE MOVING BUTTON?;….. E.G FOLLOW,SHARE, COMMENTS ETC…. KINDLY INFORM ME AT CONCEPTUAL92@GMAIL.COM
thanks for such a usefull post it solve my problem in a minute.
Thanks for the tip about putting the Google Analytics code in the footer. Works well.
Hi Paul,
Glad it was a help Paul
Thanks for leaving a comment
Kimi.
I didn’t understand why you said we need to use the plugin?? adding code in footer.php is normal code modification method….i m bit confused about that!!!!
hi Kimi
thank u very much for this post, it saved me ..i just confused that the steps i have read in google analytics website after i made an account is that to paste the code in each page , ..i noticed u have have pasted it once in the footer .. can u explain to me this differance
best regard
Hi Egami,
Yes, I only paste in the footer.php, since a wordpress theme is usually connected to footer.php file whenever it is opened.
I hope this can help
Thanks for visiting my blog,
Kimi
Hi,
I do not see the footer.php option under “Appearance” in wordpress. Could you kindly help me. Thank you in advance.
Sean
Hi Sean,
It can depend on the theme you’re using, you probably use a theme which has different file structure as the theme I used in this tutorial.
You can use a plugin for this alternatively.
Kimi.
Thanks Kimi,
Useful tutorial, when I was searching Google, landed here.
Thanks very much Kimi. I was stuck for an hour figuring out how to paste my google-analylics code. Then, searched on google and found your post. You really made my day. Thanks again.
Thanks Kimi for this helpful tutorial on adding google analytic code, actually my theme had an option to add the code directly but some how it was not functioning properly. Let see how it works. Anyway thanks π
Thank you very much for your clear and concise instructions! I am building my blog with relatively no knowledge of the internet, so websites like yours are extremely helpful!
THANKS!
thanks so much Kimi. Im glad i landed on your tutorial. youve just saved me hours of researching π