How to Add Google Analytics to your WordPress code

First, you’ll need to get your tracking code. Here are the steps (taken from Google):

  1. Log in to Google Analytics at http://www.google.com/analytics
  2. From the Overview page, select the account that has the profile for the tracking code you’re looking for
  3. Select the profile from the accounts Overview page.
  4. From that profile’s Actions columnĀ  on the end, far right, click Edit
  5. At the top right of the ‘Main Website Profile Information’ box, click Check Status
  6. Your tracking code can be copied and pasted from the text box in the Instructions for adding tracking section

Now, you will need an FTP program (a free one can be found at Filezilla-project.org)

  1. Login to your server (you might need to contact your hosting provider if you need a username, hostname and password for this)
  2. Next, open your WordPress theme folder (located in wp-content/themes/nameofyourtheme) and find a file called header.php
  3. Copy this file to your computer using the FTP program.
  4. Using a HTML editor orĀ  “Notepad” on a PC, open header.php on your computer
  5. Copy and paste the tracking code from the Google site into the head section of your HTML code, immediately preceding the </head> tag.
  6. Upload header.php to your site into the same folder listed above using the FTP program

—————————————————–

After a while, login to http://google.com/analytics and make sure there is a checkmark under status to know you did everything correctly.

That’s it.