How to Install Google Analytics on WordPress?

0
132
Install Google Analytics on WordPress

Using Google Analytics on WordPress is a great way to keep a check on your website’s traffic as well as the activities of the visitors. It is a free tool by Google that helps to analyze a website and get a wide variety of useful information ranging from its traffic to its sales or revenue it can generate.

A website is considered to be at the center of the digital marketing efforts of any business. Google Analytics comes in handy for assessing the performance of the website along with the digital presence of a company. Also, it is a highly beneficial tool that helps in improving the effectiveness of any campaign or advertisement run to promote a business’s products or website.

What Do You Understand by Google Analytics?

Google Analytics is an essential tool for growing your audience base as it gives valuable insights about the visitors while tracking them on it. Well, it’s a powerful tool to analyze and understand the traffic that lands on a website. Millions of websites use it as a way to understand their user-behavior, and explore potential customer base.

The below article provides information on different aspects of Google Analytics while answering your query – How to install Google Analytics on WordPress?

Why is there a Need for Google Analytics?

Once you start your website on WordPress, it’s essential to know its performance in terms of traffic, revenue, and other useful data. You just need to add a JavaScript code to your page, which lets Google track the activities of audiences that visit your site. This information is then put across in the form of detailed statistics, which you can access from your Google Analytics account.

Here’s how Google Analytics helps:

  • Identify the source of your traffic – Google Analytics tells you the source of your website’s visitors, the channels they use to land the website, the countries from where visitors are coming, etc.
  • Understanding your visitors – With Google Analytics, you also get to know what your visitors do, which pages they have visited the most, how they navigate through the website, and how long they stay on your website.
  • Create content that people prefer – Google Analytics helps track your traffic and tells you about the posts that have been most popular among the audience. This guides website owners to create similar content and cover topics that can help the website to gain more visitors.
  • Track the sales and conversions – If it is an e-Commerce website, then Google Analytics helps in tracking conversions as well as the revenue it’s making.
  • Track marketing campaigns – Check whether your efforts are really working in terms of sales, revenue, popularity, etc.
  • Improve the user experience – Google Analytics is also vital for understanding your audience’s behavior on your site. By knowing the browser they use and the pages they visit more, you can improve the overall user experience of your website.
  • Know your worst-performing pages – Another great benefit of Google Analytics is that we get to know the weak points of a website and strive to make it better.

How to Sign Up with Google Analytics?

We’ve mentioned 5 easy steps here to help you sign up with Google Analytics.

1. Log In

The foremost thing you need to do is head to the Google Analytics homepage and sign up on it. If you already have a Google account, you simply log in or create a new account.

Using Google Analytics on WordPress is a great way to keep a check on your website's traffic as well as the activities of the visitors. It is a free tool by Google that helps to analyze a website and get a wide variety of useful information ranging from its traffic to its sales or revenue it can generate. A website is considered to be at the center of the digital marketing efforts of any business. Google Analytics comes in handy for assessing the performance of the website along with the digital presence of a company. Also, it is a highly beneficial tool that helps in improving the effectiveness of any campaign or advertisement run to promote a business’s products or website. What Do You Understand by Google Analytics? Google Analytics is an essential tool for growing your audience base as it gives valuable insights about the visitors while tracking them on it. Well, it’s a powerful tool to analyze and understand the traffic that lands on a website. Millions of websites use it as a way to understand their user-behavior, and explore potential customer base. The below article provides information on different aspects of Google Analytics while answering your query - How to install Google Analytics on WordPress? Why is there a Need for Google Analytics? Once you start your website on WordPress, it's essential to know its performance in terms of traffic, revenue, and other useful data. You just need to add a JavaScript code to your page, which lets Google track the activities of audiences that visit your site. This information is then put across in the form of detailed statistics, which you can access from your Google Analytics account. Here's how Google Analytics helps: Identify the source of your traffic - Google Analytics tells you the source of your website’s visitors, the channels they use to land the website, the countries from where visitors are coming, etc. Understanding your visitors - With Google Analytics, you also get to know what your visitors do, which pages they have visited the most, how they navigate through the website, and how long they stay on your website. Create content that people prefer - Google Analytics helps track your traffic and tells you about the posts that have been most popular among the audience. This guides website owners to create similar content and cover topics that can help the website to gain more visitors. Track the sales and conversions - If it is an e-Commerce website, then Google Analytics helps in tracking conversions as well as the revenue it’s making. Track marketing campaigns - Check whether your efforts are really working in terms of sales, revenue, popularity, etc. Improve the user experience - Google Analytics is also vital for understanding your audience's behavior on your site. By knowing the browser they use and the pages they visit more, you can improve the overall user experience of your website. Know your worst-performing pages - Another great benefit of Google Analytics is that we get to know the weak points of a website and strive to make it better. How to Sign Up with Google Analytics? We’ve mentioned 5 easy steps here to help you sign up with Google Analytics. Log In The foremost thing you need to do is head to the Google Analytics homepage and sign up on it. If you already have a Google account, you simply log in or create a new account. Create an Analytics Account Add a name for your account and check the data sharing settings below the Account name field. You can track multiple websites with a single Google Analytics account; therefore, it's better to choose a proper account name. If you wish to use the enhanced demographics and interests report, you can check off the first data sharing option out of all the options. Creating a Property It simply means setting up a website or an application you wish to track using your Google Analytics account. So, if you want to install Google Analytics on WordPress through a plugin, create a property with the older version of Google Analytics called Universal Analytics. Finishing the Setup This step will ask the user for more details of their website or business. However, this is optional, and you can conveniently choose to skip it by clicking the 'Create’ button at the bottom of the page. You will be redirected to your account and need to configure what emails you wish to receive from Google Analytics. It won’t matter if you don't select any. After making sure, everything’s done, click on the Save button. Set up a Data Stream Datastream refers to sources of data that the user wishes to track. You can set up a data stream through an Android or iOS application or web property. Note: This step is automatically completed if the user sets up both types of Google Analytics properties. The most obvious option to add Google Analytics to a WordPress site is the Web. Once you do it, the user will be asked to create a website address and a name for a data stream. You have the choice to select the type of data you wish Google Analytics to collect. See additional options and click on +3 or click on the toggle bars next to each option for a more detailed description of them. Once you click on Create Stream, you are done; you can always change these settings later. Search your ID and Tracking Code To add the tracking code to the WordPress website, the user will first need to generate the code or the measurement ID. The user can always find their tracking code in Admin>Data and select the stream's name. However, if you use Universal Analytics, you can do the same in Admin>Property>Tracking Info>Tracking Code. What is Better? Installing Google Analytics With or Without Plugin? A lot of us believe that the fewer the plugins, the better the performance of a WordPress website. Well, this holds true until you’re using a lightweight and good-quality plugin, which will help you save a lot of time without slowing down your website. Yes, since a plugin does most of your manual work of keeping your website optimised, it’s a wise decision to use good-quality plugins. Here’s why you should use a plugin to install Google Analytics with your WordPress website: A plugin makes it easier to install Google Analytics with a WordPress site as the whole process requires just a few clicks. Plugins make it possible to track the website traffic data even when you are switching between themes. If you are manually adding the Google Analytics tracking code to your website pages, you may forget to add tracking code to the new theme. Therefore, plugins not only ensure that your website’s traffic data is tracked continuously but also saves you from all the hassles of adding the tracking code manually to your website. Without a plugin, users will not be able to use important features like custom dimensions, events tracking, file downloads tracking, etc. How to Install Google Analytics on WordPress using a Plugin? There are numerous plugins available that can be used to install Google Analytics on the WordPress site. However, it is important to note that the functionality and speed of the plugin matter to a great extent as the more plugins you use, the more heavy your site becomes. So, it's better to keep all the aspects in mind while installing Google Analytics on WordPress with a plugin. Here's a step-by-step guide to install Google Analytics using the ‘Site Kit by Google’ plugin: Step 1 - Install the Plugin Search for the Plugin in Plugins>Add New and once you find it, click on the Install Now button. The plugin will be downloaded and installed on your site, and you will have to activate it Step 2 - Set Up the Plugin After activating the plugin, you will see a prompt on your screen with a Start Setup button. Click on the button to get started. Now log in to your Google account by clicking on Sign In. Once you choose the account you want to sign in with, Google will ask you to grant a few permissions. Next, verify the site ownership and grant access to the Google account data while adding the site to the Search Console. Step 3 - Connecting to Google Analytics Once you are done, the site will get connected to Google Search Console. And now you can see the Plugin on the WordPress dashboard. Now go to Analytics and click on the blue link which will set it up. It will take you to a page to choose a Google account which will ask for some permissions. Here, you need to choose the account Google account related to your WordPress site for which you wish to connect it to GA. However, this won't work with Google Analytics 4. Go to the appropriate option and select Configure Analytics. Your website will be connected to Google Analytics. Step 4 - Check the Plugin Now all you need to do is to view the details Google has on your site in the WordPress dashboard. Under the Google Analytics section, you will see a few basic details about your site like audience overview, acquisition channels, and top content. You can also switch the time duration that you view the data for, plus you have links that take you to different pages in Google Analytics. Go to the Plugin>Settings>Connected Services and with the arrow button open the Google Analytics settings. You have the option to change the settings with the Edit link. Installing Google Analytics on WordPress Manually or Without a Plugin If you wonder how to install Google Analytics on WordPress without using a plugin, here is the process: Once you sign up on your Google Analytics account, you will need the tracking code and place it on your website. Firstly, get a child theme installed on your WordPress site for adding Google Analytics code to the functions.php file. The child theme stores any modifications that are made even after the parent theme is updated by the user. The next most important part of installing Google Analytics on WordPress without a plugin is to get the Tracking Code. Here's how you can get the tracking code manually after completing the sign up on Google Analytics: Step 1 - Sign in to your Google Analytics account and click on the Admin menu at the bottom of the screen. Step 2 - Select Tracking Info and then go to the Tracking Code menu. Step 3 - You will be able to see your Tracking ID and Global Site Tag, which you must save for later use. Start with the configuration once you get the tracking code. Functions.php Code There are several methods to add Google Analytics to WordPress via the code snippet. The first and the foremost location to add Google Analytics tracking code is the functions.php file. Create a new function that consists of the code snippet. Follow these steps to do it. Note: As a precautionary measure, we suggest you create a backup of the functions.php file before you make any changes to it. Step 1 - Go to the Theme Editor on the WordPress dashboard Step 2 - Click on the Theme Functions (functions.php) on the right column Step 3 - Now add the code snippet shown below to your template.js file and replace the Tracking ID mentioned mentioned below with yours: function ns_google_analytics() { ?> <script async src="https://www.googletagmanager.com/gtag/js?id=G-B175YGY1T1"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-B175YGY1T1'); </script> <?php } add_action( 'wp_head', 'ns_google_analytics', 10 ); Step 4 - End with selecting the Update File button and save the changes that you made Header.php Code The Google Analytics tracking code can also be added to the Theme Header. Follow these steps to add the code using this method: Step 1 - Go to the Theme Editor again Step 2 - Now select and open the Theme Header Step 3 - Copy and paste the code snippet above the <head> tag or in the header section Step 4 - If you are done, click on the Update File button and save the changes To Wrap it Up Hope you find the above information helpful for installing Google Analytics on your WordPress website. Google Analytics provides useful data and guides website owners to make data-driven decisions to grow their business more efficiently. If you have any queries, please feel free to drop them in the comment box below.

2. Create an Analytics Account

Add a name for your account and check the data sharing settings below the Account name field. You can track multiple websites with a single Google Analytics account; therefore, it’s better to choose a proper account name.

GA Account Name

If you wish to use the enhanced demographics and interests report, you can check off the first data sharing option out of all the options.

3. Creating a Property

It simply means setting up a website or an application you wish to track using your Google Analytics account. So, if you want to install Google Analytics on WordPress through a plugin, create a property with the older version of Google Analytics called Universal Analytics.

Creating a Property

4. Finishing the Setup

This step will ask the user for more details of their website or business. However, this is optional, and you can conveniently choose to skip it by clicking the ‘Create’ button at the bottom of the page.

Finishing the Setup

You will be redirected to your account and need to configure what emails you wish to receive from Google Analytics. It won’t matter if you don’t select any. After making sure, everything’s done, click on the Save button.

My Email Communication

5. Set up a Data Stream

Datastream refers to sources of data that the user wishes to track. You can set up a data stream through an Android or iOS application or web property.

Note: This step is automatically completed if the user sets up both types of Google Analytics properties.

The most obvious option to add Google Analytics to a WordPress site is the Web. Once you do it, the user will be asked to create a website address and a name for a data stream.

Set up a Data Stream

You have the choice to select the type of data you wish Google Analytics to collect. See additional options and click on +3 or click on the toggle bars next to each option for a more detailed description of them.

Enhanced Measurement

Once you click on Create Stream, you are done; you can always change these settings later.

6. Search your ID and Tracking Code

To add the tracking code to the WordPress website, the user will first need to generate the code or the measurement ID.

Tracking Code

The user can always find their tracking code in Admin>Data and select the stream’s name. However, if you use Universal Analytics, you can do the same in Admin>Property>Tracking Info>Tracking Code.

What is Better? Installing Google Analytics With or Without Plugin?

A lot of us believe that the fewer the plugins, the better the performance of a WordPress website. Well, this holds true until you’re using a lightweight and good-quality plugin, which will help you save a lot of time without slowing down your website. Yes, since a plugin does most of your manual work of keeping your website optimised, it’s a wise decision to use good-quality plugins.

Here’s why you should use a plugin to install Google Analytics with your WordPress website:

  • A plugin makes it easier to install Google Analytics with a WordPress site as the whole process requires just a few clicks.
  • Plugins make it possible to track the website traffic data even when you are switching between themes. If you are manually adding the Google Analytics tracking code to your website pages, you may forget to add tracking code to the new theme. Therefore, plugins not only ensure that your website’s traffic data is tracked continuously but also saves you from all the hassles of adding the tracking code manually to your website.
  • Without a plugin, users will not be able to use important features like custom dimensions, events tracking, file downloads tracking, etc.

How to Install Google Analytics on WordPress using a Plugin?

There are numerous plugins available that can be used to install Google Analytics on the WordPress site. However, it is important to note that the functionality and speed of the plugin matter to a great extent as the more plugins you use, the more heavy your site becomes. So, it’s better to keep all the aspects in mind while installing Google Analytics on WordPress with a plugin.

Here’s a step-by-step guide to install Google Analytics using the ‘Site Kit by Google’ plugin:

Step 1 – Install the Plugin

  • Search for the Plugin in Plugins>Add New and once you find it, click on the Install Now button.

SiteKit by Google

  • The plugin will be downloaded and installed on your site, and you will have to activate it

Step 2 – Set Up the Plugin

  • After activating the plugin, you will see a prompt on your screen with a Start Setup button. Click on the button to get started.

Site Kit Setup

  • Now log in to your Google account by clicking on Sign In. Once you choose the account you want to sign in with, Google will ask you to grant a few permissions.

Welcome to Site Kit

  • Next, verify the site ownership and grant access to the Google account data while adding the site to the Search Console.

Step 3 – Connecting to Google Analytics

Once you are done, the site will get connected to Google Search Console. And now you can see the Plugin on the WordPress dashboard.

  • Now go to Analytics and click on the blue link which will set it up. It will take you to a page to choose a Google account which will ask for some permissions.

Google account

  • Here, you need to choose the account Google account related to your WordPress site for which you wish to connect it to GA. However, this won’t work with Google Analytics 4.
  • Go to the appropriate option and select Configure Analytics. Your website will be connected to Google Analytics.

Connect Service

Step 4 – Check the Plugin

  • Now all you need to do is to view the details Google has on your site in the WordPress dashboard.
  • Under the Google Analytics section, you will see a few basic details about your site like audience overview, acquisition channels, and top content.
  • You can also switch the time duration that you view the data for, plus you have links that take you to different pages in Google Analytics.
  • Go to the Plugin>Settings>Connected Services and with the arrow button open the Google Analytics settings. You have the option to change the settings with the Edit link.

Connected Services

Installing Google Analytics on WordPress Manually or Without a Plugin

If you wonder how to install Google Analytics on WordPress without using a plugin, here is the process:

Once you sign up on your Google Analytics account, you will need the tracking code and place it on your website.

Firstly, get a child theme installed on your WordPress site for adding Google Analytics code to the functions.php file. The child theme stores any modifications that are made even after the parent theme is updated by the user.

The next most important part of installing Google Analytics on WordPress without a plugin is to get the Tracking Code.

Here’s how you can get the tracking code manually after completing the sign up on Google Analytics:

Step 1 – Sign in to your Google Analytics account and click on the Admin menu at the bottom of the screen.

Step 2 – Select Tracking Info and then go to the Tracking Code menu.

Step 3 – You will be able to see your Tracking ID and Global Site Tag, which you must save for later use.

Start with the configuration once you get the tracking code.

1. Functions.php Code

There are several methods to add Google Analytics to WordPress via the code snippet. The first and the foremost location to add Google Analytics tracking code is the functions.php file. Create a new function that consists of the code snippet. Follow these steps to do it.

Note: As a precautionary measure, we suggest you create a backup of the functions.php file before you make any changes to it.

Step 1 – Go to the Theme Editor on the WordPress dashboard

Step 2 – Click on the Theme Functions (functions.php) on the right column

Step 3 – Now add the code snippet shown below to your template.js file and replace the Tracking ID mentioned below with yours:

function ns_google_analytics() { ?>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-B175YGY1T1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-B175YGY1T1');
</script>
<?php
}
add_action( 'wp_head', 'ns_google_analytics', 10 );

Step 4 – End with selecting the Update File button and save the changes that you made

2. Header.php Code

The Google Analytics tracking code can also be added to the Theme Header. Follow these steps to add the code using this method:

Step 1 – Go to the Theme Editor again

Theme Editor

Step 2 – Now select and open the Theme Header

Step 3 – Copy and paste the code snippet above the <head> tag or in the header section

Step 4 – If you are done, click on the Update File button and save the changes

To Wrap it Up

Hope you find the above information helpful for installing Google Analytics on your WordPress website. Google Analytics provides useful data and guides website owners to make data-driven decisions to grow their business more efficiently. If you have any queries, please feel free to drop them in the comment box below.

LEAVE A REPLY

Please enter your comment!
Please enter your name here