How-to add Google Analytics tracking code to wordpress

You may add the Google Analytics tracking code to you site either manually or with a plugin. There are many plugins that can help you do this, but I have selected a very simple one, that get the job done simple and sweet.

Adding Google Analytics manually

  1. Login wordpress admin panel
  2. Goto Appearance > Editor (theme editor)
  3. Select the footer.php or index.php
  4. Find the </body> html tag
  5. Copy and page the Google Analytics code before the </body> tag.
  6. Don’t forget to click Update File to save changes.

The only problem with the manual installation is that if you swap your wordpress themes you will loose your  Google Analytics tracking. That is why it is better to handle the Google Analytics tracking code within a plugin. The selected plugin is a simple plugin with no-mumbo-jumbo.

Where do I find my UI tracking code ?

  1. Log in to Google Analytics at
  2. From the Overview page, select the account that has the profile for the tracking code you’re looking for, as the code is profile-specific.
  3. Select the profile from the accounts Overview page.
  4. From that profile’s Actions column, 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

Adding Google Analytics with the Header-Footer plugin

  1. Download and install the Header-Footer plugin
  2. Goto Settings > Header-Footer
  3. Cut and paste the google tracking code in the bottom footer textbox.
  4. Enjoy.

If you are looking for a more advanced feature packed plugin that can also handle the above and more, you might want to try HeadSpace2.

Please note that this tip requires wordpress installed on your webhost.


  1. says

    I changed theme about 3 times and used a plugin to deal with analytic code but I’m on my final theme because I’m happy with it so it is coded into the header.php for good reason.

    Where possible get the analytics code in the head of your header.php file and avoid having another plugin in the list for the blog to load, the files using storage space, more files to backup and you’ll be minus an sql query. The header in a WordPress theme already does a lot of work which is not required if your sticking to the same theme forever. Actually with some php removed from the header your blog will run much faster, it is a service WebTechGlobal offers with money back if you don’t notice speed increase.

    My point is plugins add to your blogs work load but are still the right option when you can see the code option having to be done too many times over the course of you perfecting your blog.


  2. David says

    I am using wordpress.COM, so there are no plugins allowed. When i go to find Edit under appearance, I see Edit CSS…is that what you are talking about…if so, the edit css upgrade is currently unavailable.

  3. Sean says

    David, unfortunately sites hosted at can not use Google Analytics tracking code. If you want to use your own tracking and plugins you should consider moving to a self hosted WordPress. See my special offer at the top of the page.

  4. Sean says

    V.C – all plugin’s for WordPress make the site a little slower since you are running more code on the server, that is exactly one or the reasons for this post, but the main advantage is that using a plugin helps you to be able to upgrade themes without manually adding the tracking code again.

  5. says

    I am confused here. In google analytics it was mentioning to keep the code in the at the end and just before and you are specifying to keep the code at . Please correct me if I am missing any thing here.