What is Google Analytics?

Google Analytics is a freemium web analytics service provided by Google since 2005, and to date, it’s the most powerful resource for developers to know how people interact with their site. When we use it for WordPress service sites, it does not only provide details of traffic brought on website, but also the browser, location and reference from which people are visiting the site. It also provides insight on the time people spend on your site, pages they visit and the rate at which they come back. Hence, the developer can plan how to bring more people on the site again and again, for more time.

Create a Google account and add your site to Google Analytics

WordPress is among the top CMS in the industry, and with its flexibility and versatility it provides numerous ways to integrate Google Analytics with your site. This article shows how to do it. But like all other Google services, a Google account is required for Google Analytics as well. If you don’t have one, create it now.

First step is to access the Google Analytics dashboard. From the top navigation menu, click on the admin link. On the admin page, you can add your website from the properties section displayed in the central column.

While adding your site as your property, you’re asked for the site details such as address, name, category and timezone.

After filling in, Google will provide you the JavaScript tracking code to add to the site.

Follow any of the methods given below to know how.

Method 1: Header.php file

Go to your WordPress dashboard and navigate to Appearances > Editor. Open the header.php file and paste the tracking code directly under the tag like below. Click on ‘Update file’ and you’re done.

  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

  ga('create', 'UA-65670891-2', 'auto');
  ga('send', 'pageview');



Note: Instead of the header file, you can also edit the footer file.

Method 2: Functions.php file

As an alternative, you can access the functions.php file in the same way and paste the following code in the file after including your own Analytics code.

// Paste your Google Analytics code from Step 4 here

Note: Only use this method if you know what you’re doing. If you don’t want to change the files of the parent theme, you can also create a child theme. Moreover, many modern themes have embedded the functionality to add the tracking code in the theme settings.

Method 3: Plugins

If you are a beginner and you don’t want to mess up with the files of your site, use a plugin. Some of the popular plugins are:

  • Google Analytics for WordPress
  • Google Analytics by Yoast
  • Google Analytics +
  • Google Analyticator
  • Google Analytics Plugin
  • Google Analytics Dashboard
  • Insert Header and Footer

Install any of the above mentioned plugins and add the tracking code from the settings of the plugin. Some plugins also allow you to view the Analytics directly from your WordPress dashboard.


After successful addition of the tracking code to your website, your site will be listed on the homepage of your Analytics Account. You can also confirm it from the ‘Properties’ column in the admin section. To view the stats of your website, you can check the ‘Reporting’ tab, but be patient because it usually takes Google 12-24 hours before your site data can be displayed properly.