How to add Google Analytics to your website

Once you start working on your website, that’s probably because you want other people to see it. You can start by sending direct links to your friends and family and they will be delighted to see your new work. And that’s where you will get your first few visitors and if your friends and family really like you, maybe more than just a few page views if they decide to take a deeper look at you work. But if you want to build a broad audience, you will have to do much more with your website.

A great way to start is installing Google Analytics. With this tool, Google gives you a free ticket to a complete site analytics. After acquiring your code, you will able to start monitoring your site’s traffic and, more importantly, see how your visitors react to your website, where they came from or for example which page is the most visited one.

Google Analytics is a very powerful tool and you may spend months researching each and every feature before you learn how to gain benefit from it, but it can also be a powerful tool for a beginner. Similarly, you can have Youtube analytics on your WordPress dashboard.

In just a few clicks, you will be able to see visitors’ behavior, pages they have visited, how long an average visitor is spending on your beautifully designed website (that’s what your friends told you, right), which browsers are they using, where they come from and really much, much more.

Since there are numberless books written on this topic, we can’t go into detail about Google Analytics in this article but we can show you how to start. So, without further ado, let’s see how to get yourself a Google Analytics account and how to connect your website to it so you can start gazing into analytics.

Create the account:

  1. Go to Google Analytics signup page
  2. Log in using your Google account or create one and finally join millions of users
  3. Sign Up
  4. If you haven’t been using Analytics on your account, you will have to click on “Sign Up” button. If you already have Analytics account, you will have to go to “Admin” tab under your Google Analytics settings and choose a “Create new account” option.

  5. Choose “website”
  6. Since you’re setting up an account for your WordPress, choose “Website” as something you would like to track (another option is Mobile App).

  7. Enter the following:
  8. Account name: a name used to identify your Google Analytics account
    Website name: a name of your website – you can choose anything you want
    Website URL: a direct link to your website
    Industry Category: Choose a category which suits you best. It won’t affect any track records but will help Google with your account.
    Reporting Time Zone: choose your location so Google can tell you correct times in the reports
    Data Sharing Settings: by default, all four settings are checked and if you want the best out of your tracking experience, you should leave them as is. Otherwise, read carefully and (un)check fields you want.

  9. Click on “Get tracking ID”
  10. Read and accept terms of service

You have completed the registration process and now you should see your tracking code. Copy the code because now you need to place it into your website. There are different ways of adding the code to your website.

Add the code to your site:

Through your theme:

If you have installed a theme, there is a chance you will find the Google Analytics Tracking Code option in your theme’s general options. If so, simply paste the code into provided form, save everything and your theme will take care of the rest – for example, a theme we have installed on one project had a similar form after which the Analytics code had been added to our footer.php template and thus onto every page of our website.

Use functions.php file:

If you don’t have that privilege, you can create a function by yourself and paste the code into your functions.php file:

  1. Open functions.php file
  2. paste the following code:
  3. <?php
    add_action('wp_footer', 'add_googleanalytics');
    function add_googleanalytics() { ?>
    // This is the place where you need to paste your Google Analytics Tracking Code
    <?php } ?>
  4. Save changes

PHP implementation:

Another option which is suggested on Google Analytics pages is PHP Implementation.

  1. Create “analyticstracking.php” file
  2. Copy the code and paste it into the newly created file
  3. Include the file into each PHP template page
  4. Open each and every template page and paste the following code right after the opening <body> tag:
  5. <?php include_once("analyticstracking.php") ?>

Use a plugin:

Since you’re working with WordPress, there is always the option where you can use a plugin. Among many, there is a free and very simple plugin named Smart Google Code Inserter

  1. Go to Plugins->Add New
  2. Search for “Smart Google Code Inserter”
  3. Navigate to Settings-> Smart Google Code
  4. Paste your Tracking Code in the Google Analytics Settings form
  5. Save changes

There you go. No matter how you have added the code to your site, your Google Analytics account is set up, active and ready for analyzing. Go to (Google Analytics) or install a mobile application so you can track your website on the move and start learning about your site.

Start Blog Book


This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

Your email address will not be published. Required fields are marked *