How to Add Google Analytics Visitor Tracking Code to your WordPress Site

Google Analytics makes it easy for you to track how many vistors visit your website and how they reached your website: Direct (they remembered your website address), Referral (they followed a link from another website), and Search Engine Results (including the search terms the visitors used to find your site).

Google Analytics is free. Just sign up for an account at http://www.google.com/analytics/.

It’s easy too: just copy and paste the code they give you into your WordPress theme. This tutorial will show you how.

Step 1: Create an Account for your Website

media_1295284718109.png

1. Log in at http://www.google.com/analytics/.
2. Click on Add new account
3. Click no the Sign Up button

media_1295284921407.png

Fill out the New Account Signup form and click on the Continue button

media_1295284982575.png

Enter your Name and Country information and click on the Continue button.

media_1295285390909.png

Agree to the terms and conditions and click on the Create New Account button.

media_1295285218703.png

Select the code from <script to </script> with your mouse button. You can also do this by clicking once in code box and using the keystroke combination CTRL-C. Click on the Save and Finish button.

media_1295285548918.png

Most premium themes contain a box where you can paste your code. This is very convenient because you don’t have to make changes to your theme’s files. Consult your theme’s documentation to find the area, click inside the box, and Edit | Paste the code (can also use the keystroke combination CTRL-V).

media_1295285823198.png

If your theme doesn’t contain an area to add your tracking code, you’ll have to edit the theme’s Footer file. From your WordPress dashboard, click on Appearance | Editor.

media_1295285846332.png

Some code will appear in the text box in the center of the screen, but that’s not the file we want. Click on Footer (footer.php) from the file listing on the right hand side. The Footer code will be loaded into the center box. Scroll down to the very bottom of the file.

Important: Editing your theme files can break your theme and keep you from accessing your website. Make sure you have good backups of the footer.php file before you proceed.

media_1295285899921.png

You want to paste the code, using Edit | Paste or the keystrokes CTRL-V, directly before the </body> tag. Click on the Save button.

media_1295286591483.png

Wait a few minutes and the status triangle should change from yellow to green. You’re done.

About David Burch

INJF. I help people with Internet Marketing, email lists, and WordPress. I am into productivity, cool tools, health and Chi Kung. I am on The Twitter and that's the best place to start a chat with me, so @ me while you're there. If you follow me, you should know that I tweet a lot.

Comments

  1. Great post David! There is a great plugin that is a timesaver for tasks like these called All-in-One Webmaster. All you have to do is add the UA Google code. No need to go into your theme files. You can also use it to submit Alexa, Yahoo Site Explore, Get Clicky, Google Webmaster site verifications and codes, plus much more.

    • David Burch says:

      Plugins like this can be good. I prefer avoiding the plugin overhead and pasted the code in myself, but I haven’t had to do that lately because most of the premium themes I use Catalyst, Genesis, Woothemes, etc. include a box in the theme’s dashboard where you can paste the code. No plugins required.

      • Hi again,

        I have Genesis and AgentPress. Where do you put the code? In the theme settings where it says: Header/Footer scripts? I have always ignored that section :-(

        Well, I guess that’s another great reason to LOVE Genesis, which I do!

  2. Adam says:

    I also use the Agent Press theme and was wondering where to put the analytics code. What did you mean by “in the footer scripts box.” I went into the editor section but just wasn’t sure where to actually paste the analytics code.

  3. David Burch says:

    AgentPress is a StudioPress theme that uses the Genesis framework. In your WordPress dashboard, select Genesis | Theme Settings. Scroll down and you’ll find separate boxes for header and footer scripts.

Speak Your Mind

*