How to Add Google Analytics to WordPress Website?

In the modern era of the internet, having a website is a must for your organization’s online presence. But is your online presence enough for your business’s growth? The one-word answer to this is NO! You need to have your presence felt as well as target your audience in the right way. You do not need to invest in showing your abilities or services of Graphic Design to a Machenic. He would rather be interested in the automotive industry instead of a graphic designer. You may be planning to apply some search engine optimization on your website. All of these would be more useful when you know your target audience and what your audience want to see on your website. Google analytics is such a tool that can help you gather all this information. You can always improve your site through results from Google analytics to make your website stand out from its competitors. Google Analytics is a standard analytic tool for Website analytics. In this article, we will look into:

What is Google Analytics?

Google analytics is a web analytics tool by Google. It helps you measure the traffic of your website and gather other important information about the visitors to your website. It provides you the information about the time and area for which website traffic is at its peak or lowest point. Here is a list of stats you can learn from Google Analytics about your website:

  • Who is visiting your site?
  • What do your visitors do?
  • At what time visitors come to your Website?
  • How do they find your site?
  • How do they interact with your content?

By using these statistics, you can always improve your site’s content, optimize traffic resources, track marketing campaigns, and improve your less performing pages and URLs. Google analytics can help you make the right decision to achieve the goals regarding website traffic and performance. It is completely free of cost with all of its rich features, which makes it the most popular analytics tool among the developers.

Configure Google Analytics

Setting Google analytics is not a difficult task at all, you may get confused when you see the google analytics dashboard. But this step by step guide will help you to figure out how to set up a Google Analytics account and then add Google Analytics to WordPress Website.

Before you configure Google Analytics, Sign up to Google if you already have not done this. Once you have a Google account you can sign up for Google Analytics at this link.

Register for Google Analytics
Register for Google Analytics

When you complete the signup process. follow these steps to configure Google Analytics account.

  1. Sign in to your Google Account.

    Sign in to Google Account
    Sign in to Google Account
  2. Create a Google Analytics Account

    Sign Up to Google Analytics
    Sign Up to Google Analytics
  3. Add new website to google analytics: When you click on Sign up button, you will see a screen prompting you to enter the details of your website. Google Analytics refers to your website as PROPERTY. You can enter details here. Name your account, Website URL, Website Name, Website Category and Time Zone.

    Add a Property
    Add a Property
  4. Google Analytics Tracking ID: Click on the “ Get Tracking ID button. You can also opt-in for some extra features from Google on this page.

    Get Tracking ID
    Get Tracking ID
  5. Get Google Analytics Code: Once you click Get Tracking ID ”, you will be redirected to the next page, which has your tracking code. Click on Tracking Info , then select analytics tracking code.

    Get Tracking Code
    Get Tracking Code
  6. Copy the code as highlighted in the above screenshot. You will be using this analytics tracking code from now on, to track your website’s performance.

Add Google Analytics to WordPress

Till now we have configured our Google Analytics Account and got the javascript snippet for tracking. Now we will learn how to use this code snippet, in order to implement Google Analytics for our WordPress website. In WordPress, we get to implement the same functionality in various ways. Same is the case here, we can paste our code in different ways. There are three ways of achieving this:

We will discuss both of these methods because both of these are used depending upon developers choice. Some developers are comfortable using a plugin for Google Analytics but some find it easy to implement without using any plugin.

Google Analytics with a Plugin

On the WordPress community, there are a number of plugins available for Google Analytics. Here is this list of a few of them:

  • Analytify
  • MonsterInsights
  • Google Analytics Dashboard for WP
  • WP Google Analytics Events

For the scope of this article, we are going to use MonsterInsights as our plugin for Google analytics. It is one of the best google analytics plugin for WordPress.

Mosterinsight
Mosterinsight

With 2+ Million active installations and 4.7- stars rating MonsterInsights is a complete analytics plugin with a dashboard that shows you actionable reports in your WordPress dashboard. It allows you to generate reports about the website in the following:

  • Audience Report
  • Behavior Report
  • Content Report
  • E-commerce Report
  • Forms Report
  • Search Console Report
  • Custom Dimensions Report

Adding Google Analytics with Plugin is an easy job to do. You just need to follow these steps and you will be good to go:

  1. Install the plugin Monsterinsights.
  2. Connect with Google Analytics. Click on Settings in the menu in Monsterinsight. Click on Authenticate with your Google account. This will redirect you to the google page. Select the account you want to use for tracking.
  3. Once logged in, Google Analytics will ask for the permissions for WordPress Plugin to access your data.

    Allow Access to Plugin
    Allow Access to Plugin
  4. Click on Allow, in order to connect successfully.
  5. Select the property you want to track, and you are all set to go.

Once connected you can go to Track and select the options of your linking. At this tab, you can make changes for how the plugin tracks your visitor. You can navigate to Insights > Reports to see the reports of your website. Monsterinsights allows you to see reports at the WordPress dashboard rather than you go to the Google Analytics dashboard.

Using these plugins may be preferred by some of the developers but if you like to have a light website dashboard without many things on it, you may like the other ways. You can implement Google Analytics by using the javascript code snippet we got from Google analytic dashboard earlier.

You will have to insert this code into header or footer of your website to connect google analytics with your website and start tracking the website’s performance.

Using Insert Headers and Footer Plugin

This plugin is used to insert custom code in header or footer of your website. This method of implementing Google Analytics is not suggested by the experts if you want to use your WordPress dashboard for analytics dashboard too. Using this will lead you to manage the analytics from Google Analytics dashboard. To use this method follow these steps:

  1. Install and activate the plugin
  2. Navigate to Settings > Insert Header and Footer. You will see:

    Insert Header and Footer
    Insert Header and Footer
  3. Paste you javascript code snippet either in header or footer section.
  4. Click on Save.
  5. That‘s it go to Google Analytics dashboard and track the performance of your website.

Google Analytics without using a Plugin

Despite having plugins available, some of you may prefer a method to implement Google Analytics without using any plugin. This method is risky as you might lose your data upon changing or updating the theme. But if you are an expert in WordPress development and know the ins and outs of theme editing, you can always do this with ease.

You can insert the code in either header.php or functions.php. Lets first discuss how to do it using header.php:

  1. Navigate to Appearance > Theme Editor
  2. Open the header.php file.
  3. Paste your analytics code just after the <body> tag.
  4. Save changes and you are good to go. You can access your analytics from your Google analytics dashboard.

Add code in the function.php file:

You can also use the function.php file in order to achieve our goal to implement Google Analytics. It will automatically enable your code in every page of the website.

    1. Copy and paste the following code in your function.php file:
      <?php add_action('wp_head', 'wp_add_googleanalytics'); <br>
      function wp_add_googleanalytics() { ?>
       
      // Paste your Google Analytics code snippet here
       
      <?php } ?>
      
    2. Save changes and access your Google analytics dashboard.

Last Say!

Google analytics has become an important part of evaluating a website’s performance. It is the most used analytics tool in recent years. The data gained from Google Analytics has helped the business owners to make the right decision towards making their website’s performance better with time. So, in our opinion, Google analytics is a must have for your website.

This article discusses how to install Google Analytics in WordPress Website.Click To Tweet

If you want to implement Google analytics and don’t have much expertise. Don’t worry we are here to help you. Contact us today to configure your Google analytics account and its integration with your website. We will be more than happy to serve you.

What we do Best

WordPress
Maintenance
you Need!

WordPress Updates

Security Checks

Daily Cloud Backups

Speed Optimization

Premium Plugins

Developer Consultation

 

Leave a Comment

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