Google Analytics for your website

August 9th 2017 - Google Analytics for your website

Reading + Setup time: 10 - 15 minutes

Step 1: Setup Analytics account


Visit Google Analytics Website and sign up.

Then setup your analytics account. This is done by creating a property for your website and supplying the domain address. In the image below, I have entered the property name and the website address. In this post, I cover only website tracking.
Google Analytics Setup Account
The next step is a bunch of options for data sharing setting that you may want enabled for your website. Since this is personal preference, I am skipping this section.
Click Get Tracking ID. Accept the terms and conditions that pop up.
Joke: After marriage, life becomes like installing a software. Whatever, the terms and conditions are, you just agree.


Step 2: Adding JavaScript tracking code to your website

This takes you to the Admin page that shows you lot of different options and tabs. It can be overwhelming at this point but all you need to do is copy the javascript code that is put up under website tracking.

If your website has multiple pages and you want to track them all, then paste the JS code on a common page. I had a html template just for the navigation bar and since the navigation bar was included in all the pages, I added the website tracking code to the navigation bar html.
Once you've added this, now you're all set.

Step 3: Testing

Famous quote in the QA community: In god we trust, everything else we test.

In order to check if the website tracking works, you can go to the admin page.
Hint: You can access the admin page in the left navigation menu. As on date 9th August 2017, it is at the bottom of the left navigation menu.
Then click on tracking code and you should see a button "send test traffic". If you have trouble finding this, CTRL + F (windows) or CMD +F(mac) will help you out.
Once you click this, navigate to your home page, you should see some data being generated.


Congratulations!! You are now successfully tracking your website with Google Analytics.



Common Errors / FAQs

  1. I added the tracking code but it doesn't work

  2. First thing to check out for is if the copy paste had been properly done. Some editors may use a different encoding that may screw things up. So check this with attention to detail.
    If the changes you made ( by adding the tracking code ) are local, make sure you push your changes to the server.
    By all means, if sending test traffic works, your tracking will.
  3. I don't see any data other than active users

  4. Yes, this is expected since other metrics such as "When do users visit?", "Geographical locations", "Page Views", etc. get generated within 24-48 hours.