Great site statistics is probably the single most important success factor of any website. The best way to know your audience is through your traffic stats and this is what Google Analytics provide for FREE. In this article, we will share why Google Analytics is important, and how you can install Google Analytics in your WordPress blog.
Why is Google Analytics Important for Bloggers?
Google analytics allow you to keep track of:
Who visits your site
This part of analytics answer what is the geographical location of your audience, which browser did the user use to visit your site and many other important information such as: screen resolution, JavaScript support, Flash support, language and more.
This data is extremely useful, and it can help in numerous ways. When getting a custom design, you can use the user data to make sure that your site will be compatible with your audience. If most of your users does not have Flash support, then you should avoid adding flash element to your site. If most of your users are on 1280 screen resolutions, then make sure that your design is compatible with that resolution or smaller.
What they do when they are on your website
You can track where the user is going on your website. How long do they stay on your website, and what is the bounce rate (the percent of users exit your site on the first visit) on your site. By using this information: you can decrease the bounce rate and increase the depth of pageviews.
When they visit your website
By looking at the hottest hours in the day for your site, you can pick the time when you publish your post. If that time zone is not compatible with yours, then you can schedule your post to meet that hour.
Where did they arrive on your website from
This section of the analytics show you where did the user came from: Search Engines, Direct Links, Referral links from another site. It shows you what percentage of your visitors came from each of these sources. Google analytics also gives you the break down of each of these categories. If it is the search engine category, then it shows you which search engine got you the most traffic, google, yahoo, bing etc. It will also show you the most used search terms by visitors, so you can improve your ranking for that keyword (Check out our Must See SEO Guide for All WordPress Bloggers). The break down of referral sites show you which sites you need to work with the most. If your top referral source is twitter, then you need to have exclusive twitter content to make your twitter audience feel special. If your top referral source is an external website, then you might want to consider having a partnership with that website (link exchanges or something else).
How they interact with your site’s content
Google analytics show how your users interacted with your site’s content. It shows you what percent of the user clicked on which link on your site and much more. By seeing the user interactivity, you can work your content around your users.
By seeing the answers to the questions above, you can focus on the strategies that work for your site and eliminate the strategies that don’t work.
How to Signup with Google Analytics
First you would need to create a Google Analytics account. To do this, visit Google Analytics Signup Page.
You will see a screen like the one below. If you already have a gmail account, then use that to sign-in with. If you do not have a gmail account, then you would have to create an account for yourself.

Once you sign-in with your gmail account, you will be prompted to a screen like the one below. This is where you will signup for google analytics with your gmail account.

The third step would be to enter your site information. The fields are pretty self explanatory. You enter your Website’s URL, Account name (it can be anything that you like), Time zone country, and the time zone.

Step 4 requires you to enter your contact information.

Step 5 would require you to agree with their terms.
Step 6 is where you will receive the code to paste in your site. This is the important part of the signup. Copy and paste this code in a notepad or a HTML editor and keep this screen open.

How to Install Google Analytics in WordPress
There are 3 ways to install Google analytics in WordPress. Direct paste, functions.php, and plugins.
Plugins Method (Recommended)
There are tons of plugins available to add Google Analytics to your site. However, it is probably best to just use a simple light-weight plugin like:
Paste the Google Analytics code in the plugin’s setting page.
Direct Paste Method
Copy the code that you received in Step 6, and paste it in your theme’s footer.php right above the </body> tag.
Functions.php Method
Note: only use this if you know what you are doing.
Add the following code in your theme’s functions.php file and don’t forget to paste your Google Analytics code from Step 6 here. Before you paste it, please make sure that you have read our Beginner’s Guide to Pasting Snippets from the Web.
<?php
add_action('wp_footer', 'add_googleanalytics');
function add_googleanalytics() { ?>
// Paste your Google Analytics code from Step 6 here
<?php } ?>
Once you have installed Google Analytics in your site, you can go back to the screen from Step 6 and click Save and Finish. Then you will be taken to the overview of your site’s analytics.

You can see the status have an exclamation work. This just means that Google hasn’t realized that you have added the code to your site. It takes Google upto 12 – 24 hours to start providing you with the awesome site stats that you need.
This is a must have for every blog, so get it now. If you have any questions then feel free to ask in the comments. If you like this article, then please share it with your friends on twitter and facebook.
Note: This is only for Self-Hosted WordPress.org blogs. Free WordPress.com sites cannot use Google Analytics. Maybe it’s time to upgrade from free WordPress.com to Self-Hosted WordPress? Consider using our Free WordPress Blog Setup program.








Thanks For This Great Tutorial
I have One Question… i installed The Header and Footers Plugin, So Now I have To paste the Google analytic script In Header of the Plugin setting or Both Header and Footer?
Thanks in advance?
Just the header would work.
Thanks a lot For The Quick Response
Thanks this helped me out a lot
I tried the plugin and the direct method but it still says tracking not installed.
From the google analytics plugin on WP i do get information, though. Any help would be greatly appreciated.
Thanks for this helpful post
What are the advantages of this over Site stats using JetPack. I have a self-hosted blog but use WordPress.com statistics that are available in the JetPack plugin.
Google Analytics is far more advanced and give you much more data. However for some beginners it can get a little complicated. Jetpack Stats give simple data, but its easy to use.
I can’t find my footer or available plugins. Is there a real step-by-step once you are in your wordpress blog ‘for dummies’? Help!
If you can’t add plugins, then you are probably using WordPress.com. This will only work for self-hosted sites.
Amazing blog post it worked nicely! Thanks again
That is what it is about getting useful information thanks for the details it makes it so simple to have something you can follow step by step… Thank you rock on brother
Thank you for the clear stepwise description. I had already an account with Google Analytics showing the results on the website. Now I copied the script code in the functions.php, so far so good. Where and when can I expect the GA output now? Is it displayed in the footer?
BTW: I don’t use a standard theme, but one built from scratch so maybe I miss something?
Thnx in advance, Leo
The output is not visible unless you view the source code of the page. You should see it towards the bottom in the source code.
The title of this post suggests that you can have GA data at your site. But if is not visible, what’s the use then?
Most tracking software will NOT make your data visible to the general public. Google analytics is a tracking software. You install it on your WordPress site, so you can get better insights about your audience. Google analytics works silently behind the scenes to capture data about your audience such as (what time they visited your site, who referred them, which pages they viewed etc).
Thanks so much for this info. It helped me overcome my paralysis with anything related to code. It was really useful!! Cheers Louise
Where do you get the code from step 6 if you do not get it the first time? I do not see it again when I log in.
Login to Google Analytics. Look in the orange bar where it says Admin. Click on that. Under the accounts, click on the account that you want the code of. Under that account, you will see the property. Click on that property. There you will see a tab for Tracking info.
This helped me a lot! But how do I do to measure my subdomains in the same account?
When getting your code, it has an option for subdomains there.
I wanted to do the paste. I made it to the footer.php page but there is no tag on that page so I can’t paste before it. What am I missing? Plus, I closed the Google page before reading your instructions not to do so. (I did copy the code.) Do I need to start over with Google? Thanks.
No you do not. Just use the plugin we are recommending in the article above, and it will take care of it.
Thanks! The header and footer plugin helped me a lot!
Thank you for this post.
I am totally new in blogging and has recently set up a blog using wordpress platform.
I have set up analytics account and paste the code using my theme’s option.
Now my account is showing that tracking code installed.
But the problem is in the audience section it is showing 0 visits while in the real time section it is showing 2 visitors.
I am totally confused.
( My blog is under construction. Me and one of my friend is the only visitor. And I was unable to find single domain option. there are subdomain, mutiple top level domain options but no single domain option.)
Can you please help me.
The stats does take some time to be updated.
I’m not at all sure what I am doing so perhaps you can help. Someone else that is not available now laid out my site. I was told to cut and paste the Google Analytics code one line below this last line of each page of my simple WP site. However, I cannot see where to do that for the Home Page. There is not a tab for the Home Page from the Dashboard. Any help is appreciated.
Use our plugin that we mentioned, and it will add it on all pages of your site.
Does this plugin work retrospectively: that is to say, does it enter the the code into existing headers for pages that I’ve already developed on my WordPress site? I’ve put the script code in the header section and pressed save settings, but I’m not sure that that’s all I need to do.
Any assistance would be gratefully received.
Yes it does.
Hi, great tutorial. Just one question. I have a desktop site and a mobile site. They both use different themes but have the same domain (www.dapopeyoh.com), so do i enter the google code in the footer.php file of one theme or both themes? Thanks.
Both themes.
Thank you so much for guiding me. I’ve completed and now waiting for 12-24 hours
I used the “Insert Header and Footer” plugin and pasted the google analytics code into the header in the settings of the plugin. I saved the settings and when I log into google analytics, the status is still “tracking is not installed.” Did I do something wrong and do I simply have to wait a while?
If it is not working, then it means that your theme does not have wp_head(); in the header.php which is a standard for all WP themes.
So how would we be able to include the wp_head(); to the site?
I have the same issue (I think) – tried different ways but tracking still stating not installed.
It is supposed to be included in your theme’s header.php file in the head markup.
We have just started a WP blog as a sub-directory to our main site. We used the main site analytics code in the WP blog but I am not seeing any information about the pages visited in the blog. Should we create a separate analytics account for the blog sub-directory? If so, will that show us information about where visitors move from the blog to the main site?
Yes, there is an option in Google Analytics to get subdomain analytics code.
Hi. Thanks for this tutorial. It simplified my life using the plugin to insert the code. I was wondering thoughif theres a way to get previous months data into google analytics? I only installed the code now and opened an account. Just wondering.. Thanks in advance. Great work!
It cannot show you the data of things it didn’t track. The only way google can give you the data is if their script is on your page. Otherwise, they can’t.
I followed the instructions to pate in footer.php, and the Tracking status shows “Receiving Data”.
However, when I go to the bottom of the Word Press Dashboard, to the Google Analytics Dashboard Widget, there is a note:
“You need to log in and select an account in the options panel.”
On clicking the options panel or Settings -> Google Analytics Dashboard, I get the following error:
“Error gathering analytics data from Google: GDatainsufficientPermissionsUser does not have any Google Analytics account. Please try again later.”
The problem is later does not arrive and I can find no way out.
The issue you are describing is with a specific plugin that you are using “Google Analytics Dashboard Widget”. You should ask that question in their support forum.
Hey, amazing that this is possible, but is google analytics replacing the normal wpstats ? Do you lose your views and information from that ?
Thankyou!
WP Stats is not a built-in WordPress plugin in self-hosted WordPress. Google Analytics is definitely a more robust platform.
When you open Settings>Insert Header and Footer, there are two fields. You don’t specify above whether the code is to go in one field or both.
It needs to be inserted in the header. So the first field
My Google Analytical has stopped tracking and is showing all 0′s for the past week. Can you advise why?
Is the code still added in your site? Did you change your theme? The only reason for it to be zero is if the code from your site got removed.
My Google Analytical has stopped tracking and is showing all 0′s for the past week. Can you advise why?
I looked in the footer if the code is still there, but I don’t remember what the code was or looks like (did not make a note of it so it seems…). It does not look good. So what can I do now?
Above the in the footer.php it says:
Thank you.
Login to your Google Analytics to get the code again.
hello
my wordpress site is a free one and i don’t see any option for plugins. The site is http://www.lavidavidzi.wordpress.com i’m wondering if this url has the ability to add plugins. I can’t even find the footer option you’re referring to …am i even able to get google analytics ?
Unfortunately, you can’t get those features. Refer to this chart for why:
http://www.wpbeginner.com/beginners-guide/self-hosted-wordpress-org-vs-free-wordpress-com-infograph/?display=wide
How do I add a plugin? WordPress doesn’t let me edit my coding. I downloaded one of the plugins but how do I get it on my site?
Please refer to our Videos that will show you how to add plugins in WordPress.
I tried to do this and lost everything, I think its because I put in the function.php coding in wrong but did it in the section where it said I was able to add in extra coding anyway.
My site isn’t opening, neither my admin page to correct the problem it just says theres an http 500 error, I’m clueless and scared, is there anyway I can fix this problem? Please help.
@figz91 Yes, you would need to go through the FTP. Send us an email, and we can help you fix it.
The same thing just happened to me, please help me fix this asap!
Heidi, you would have to use FTP to fix it. You are probably getting a syntax error because you pasted the code improperly.
Aloha, so I signed up for analytics and placed the code in my theme options where there was a spot for my analytics built into the wp theme. I also have a squeeze page on the blog. part of the domain and wondering do I upload the same code, or do I get another code? Thanks so much.
@AdamCollins You can use the same code. Because that is on a separate page. You can see traffic by pages in Google Analytics.
Yeh hi… i tried to follow all this and now i have lost everything! i cant even login to my admin page!!
HELP
@buckingham87 That probably happened because you pasted the code improperly in your functions.php file. http://www.wpbeginner.com/beginners-guide/beginners-guide-to-pasting-snippets-from-the-web-into-wordpress/
@wpbeginner I’m having the same problem Buckingham is and I’m about to breakdown. Regardless of why it’s happening I need to get back my 4 years worth of content and I can’t even get to my admin page let alone the actual site.
Is there anyway to fix this. I’m clueless and have no idea what to do. Please help.
Thanks it worked great!
What exactly does the following mean? I have a website that I put together compliments of Wealthy Affiliate University. Does that mean it’s a self-hosted or is it a free word press site?
“Note: This is only for Self-Hosted WordPress.org blogs. Free WordPress.com sites cannot use Google Analytics. Maybe it’s time to upgrade from free WordPress.com to Self-Hosted WordPress? Consider using our Free WordPress Blog Setup program.”
WHICH?
Go in your WordPress admin panel and click on Appearence > Editor … If you can edit all of your theme files, then you are on self-hosted.
Very useful post. How should I add tracking in case I am using WordPress as a Subdirectory? For example- http://www.domain.com/blog.
Do I copy -paste the same tracking code in the footer file or do I need to generate a new tracker code for this? I installed the analytics plug-in and configured it but somehow it never recorded visits although the data was being received successfully.