MilesWeb
USA’s #1 Web Hosting Company Since 2012
Award-winning Web Hosting Company
Everything that you need to build, host and manage a website is available at just 60/mo

3 Ways Of Adding Google Analytics To Your WordPress Website

Google analytics is a great website analysis platform that monitors the performance of all types of websites and enables the website owners to take better and timely decisions for their websites. Google Analytics analyzes various aspects of a website like page views, bounce rate, website traffic, user behavior, referral sources, website conversions etc. This information is extremely crucial for the growth and improvement of a website.

Google analytics is the most commonly used analytics tool that is available for free. Having Google analytics connected to your website provides you a better insight on the performance of your website.

There are 3 ways through which you can connect Google analytics to your website, they are mentioned below:

Option 1 : Directly Add Google Analytics To Your WordPress Theme

Google Analytics can be easily incorporated in your WordPress website without the use of a plugin. This can be done through the header.php file or through the theme functions file. However, before you do this, it is recommended to take a complete website backup before you start editing the theme files.

For adding Google Analytics to your website through the header.php file, refer to the steps mentioned below:

  • Login to Google Analytics account.
  • Copy the tracking code of the website. You can get the tracking code of your website in Admin >> Tracking info >> Tracking Code.
  • Go to the header.php file of your WordPress website and paste the tracking code after the <body> tag.
  • Click on update.

In order to add Google Analytics to your website through the function file, add the code mentioned below to the functions.php file of your WordPress theme: 

<?php

add_action(‘wp_head’, ‘wpb_add_googleanalytics’);

function wpb_add_googleanalytics() { ?>

// Paste your Google Analytics tracking code here

<?php } ?>

Option 2 : Add Google Analytics To Your Website Through The ‘Insert Headers And Footers’ Plugin

If you don’t wish to edit any theme files, then you can add Google Analytics to your website easily through a plugin. You can use the plugin – ‘Insert Headers And Footers’ for this. This is an easy-to-use plugin that enables you to insert many codes like Google Analytics, Facebook Pixel, custom CSS etc. to the header and footer of your WordPress website.

Follow the steps mentioned below for using this plugin:

  • Install the ‘Insert Headers And Footers’ plugin and activate it.
  • Login to your Google Analytics account and copy the tracking code for your website.
  • Go to the ‘Settings’ for the plugin.
  • Paste the Google Analytics tracking code in the ‘headers’ section.
  • Save the changes.

Option 3 : Connect WordPress And Google Analytics Through MonsterInsights

MonsterInsights is another useful WordPress plugin that enables you to add Google Analytics to your WordPress website. MonsterInsigts also offers advanced tracking options and provides you with a Google Analytics dashboard in the WordPress admin area so that you can view the real time stats and data about your website.

Here’s how you can use this plugin:

  • Install the ‘Google Analytics by MonsterInsights’ plugin and activate it.
  • Go to ‘Settings’ under the ‘New Analytics’ menu in the WordPress admin bar.
  • Connect your Google Analytics account to your website through any of these two ways mentioned below:
    • Authenticate the plugin through your Google account : If you are logged in to your Google Analytics account, click on ‘Authenticate’ and follow the instructions after that.
    • Enter the UA (user account) code manually : Check this box – ‘Manually enter your UA code’. After checking this box, paste your Google Analytics tracking code along with your UA number.
  • Save the changes.

An Important Note:

Google Analytics will only start tracking the data of your website from the time when it was connected to your website. You might not be able to view the data right away. You need to give approximately 24 hours to Google for crawling your website and then you will start seeing data about your website traffic and visitors.

Ujwala

My aim is to create enriching content on topics related to SEO, web hosting and social media. The idea is to elevate the readers to new levels of usability, accessibility and understanding.

Leave a Reply

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