If you’re running a blog or a business website, it is important to track the performance of the website and how viewers engage with your webpages. The most popular web analytics tool that can provide you a wealth of data is Google Analytics. Google analytics is free to use and can provide you detailed and actionable information about visitors to your website.

The following steps will help you setup the Google Analytics tracking on your website.

Step 1: Create a Google Analytics Account

To start using Google Analytics, you will first need to create a Google Analytics account by visiting this URL: http://www.google.com/analytics

Note that when you create a new account, you can use your existing Google/Gmail account to create a Google Analytics account.

Step 2: Setup a Property

A property is a website for which you’re setting up the analytics tracking. Within one Google Analytics account, you can create multiple properties, one for each website that you own.


Step 3: Get the Tracking Code

Once you have setup the property, you will get the tracking code and the tracking ID. Copy and paste the tracking code in a notepad.


Step 4: Install the Tracking Code

Now that you have the tracking code, you’re ready to install it. Login to WordPress or any other CMS that you’re using and open your website code in the HTML editor.

You must place the script at the top of every page on your website. The correct location is immediately after the <body> tag on the pages. This will typically be done in the header.php file in your WordPress theme. To edit this file, visit Appearance > Editor in the WP Admin Dashboard. By default the stylesheet file of your active theme will be open for editing. From the right panel, select the appropriate header file (in most cases this is header.php).

Open the header file, and paste the Google Analytics tracking code just after the <body> tag. This is the opening tag for HTML body.

In the above method, we described how we can directly paste the tracking code in HTML pages. Alternatively, you can also make use of the many Google Analytics plugins available on WordPress.org.