How to Install the Google Analytics Code on Your Website

What you need to install Google Analytics

Before you start, you need to make sure you have a few things:

  • A Google Analytics account
  • Access to the source code of your website
  • An FTP client (CoreFTP on a PC or Cyberduck for Mac are both free)
  • A text editor (Notepad on a PC or Textedit on Mac are fine)

A little HTML knowledge wouldn’t go amiss, for confidence more than anything. It is a very simple process that requires little more than copy and paste.

Create a site profile

Once you’re signed into Google Analytics you will first have to create an account and a site profile within it. To do this:

  • Sign in to your Google Analytics account
  • Click the settings button on the top right (looks like a little cog on the orange header bar)
  • Add a new account

You will be asked to add your site details during the account creation process, but if you have any others you can easily add them later by going into settings, clicking on the account name and then clicking ‘+ New Web Property’.

Finding the tracking code

Each site will be assigned a unique tracking code that you need to add for Google to collect the data that will show up in your Google Analytics account.

To access this code simply go to the relevant site profile in your account and click the ‘tracking code’ tab. You will then be presented with the code that you need to add to the site.

Adding the Google Analytics tracking code

This is where you will need a little knowledge of how your site is put together. The tracking code has to be placed before the ending tag of each page.

If your site is pure HTML, this means you have to insert it into each individual page. If it’s based on WordPress or some other PHP based platform, there will probably just be one file you have to add it into. It’s usually called tail.php or footer.php

  • Download this file (or all pages if HTML) using your FTP client and open it/them in your text editor
  • Copy the tracking code from your Google account
  • Paste it in as the last entry before the tag
  • Upload the updated file(s) to your site using the FTP client

Allow 24 hours for data to show up, and if it’s a new site, perhaps get a few friends to visit to make sure there are visits to record.
Congratulations! You’ve now installed Google Analytics and you can now start tracking your website’s search engine optimisation progress.