Home » Blog » How to Add Google Analytics to WordPress with or Without a Plugin

Digital Marketing

Add Google Analytics to WordPress 1

How to Add Google Analytics to WordPress with or without a Plugin

Dev eWayCorp November 21, 2022 9 MIN READ

Digital Marketing

Add Google Analytics to WordPress 1

Planning to add Google Analytics to WordPress? You are not alone. A lot of WordPress website owners are clueless when it comes to adding Google Analytics to WordPress.  

In fact, they do not even know how to add tracking codes to their website. But there is nothing to worry about. This blog post will cover everything, right from the need for Google Analytics (GA) to how to use it for WordPress sites, and many more things. 

Just creating an informative website is not enough for any business professional. Many more things need to be done, such as optimizing the site for increased visibility and ranking or understanding how the visitors are interacting with the site content.  

In an equivalent manner, keeping track of the visitors that a site and any individual pages receive is important since it helps business houses know the source of their website traffic. Plus, businesses can know their audience better. So, this step is crucial for any size and type of business.  

And what could be a better way to analyze the traffic that a site receives than using Google Analytics?  

According to a study, around 80% of WordPress site owners use GA to get traffic stats for websites. Based on the inputs, digital marketers and site owners can make improvements to the site so that it offers visitors a great user experience.  

Now, in this post, we will discuss Google Analytics in detail and how to connect Google Analytics (GA) to a WordPress site. 

Google Analytics: Best Tracking Tool in the Market 

Although there are many analytics tools available online, settling down for GA is always a clever idea. This is because Google Analytics is one such tool that is present across millions of websites, including WordPress.  

Plus, this web analytics tool offers accurate results to marketers on which they can start working. On top of that, GA is one such analytic tool that is free to use. 

Google Analytics: What is It? 

Do you know about Google Analytics? In case you have no idea, you do not need to freak out. This blog post will help you to get a clear picture of this tool. 

Google Analytics is a popular web analytics tool. Basically, it gathers information related to web traffic and makes it available to digital marketers and business professionals in the form of graphs and statistics.  

To turn the available data into graphs and statistics, a JavaScript code needs to be added to the site. In turn, this allows the software to track down every visitor and their activities on the website. Once the tracking is done, Google Analytics turns the information into graphs. 

With GA, one can easily monitor the traffic that a site receives. Plus, it allows the users to dig deep into the insights and evaluate the performance of the site.  

In other words, Google Analytics is a comprehensive platform that offers comprehensive data related to website traffic. This data can help businesses understand their audience and serve them in a better way. 

How is Adding Google Analytics to WordPress Helping Businesses? 

Particularly, Google Analytics is helping businesses in the following ways: 

1. Knowing the Visitors 

Site owners can learn about the visitors, their locations, and the devices they are using to access the site. In short, the tool offers complete data related to demographics and location. For instance, countries or regions that are driving the traffic. 

2. Tracking Their Activity 

Google Analytics helps site owners check how long the visitors stay on the site or any individual page. Plus, the pages that are frequently visited. Or the links clicked by the visitors. 

3. Peak Time of Traffic 

This gives site owners a clear picture of the time of the day or week or month during which it pulled enough traffic. 

4. Business Source 

Google Analytics can tell the primary source of traffic for the site. Usually, the sources are social media, search engines, links, and organic traffic. 

Along with the Google Analytics report, an advanced report can help to track certain activities, such as email list subscriptions or even eCommerce sales. 

So, when businesses have an analytics tool like GA, they not only get to view web traffic on a real-time basis but also understand user behavior. For instance, it provides information regarding the active users on the site at any given time.  

Why do Businesses Need Google Analytics? 

GA even offers information related to the age, gender, and geographic location of the visitor. Plus, it offers information related to conversion rate, CTR, and even the bounce rate.  

Hence, with all this available information, businesses can improve their site’s performance and optimize it for better results. To make a website perform better, it is important to make Google Analytics a part of the site.  

Why is Analytics so Important for WordPress Sites? 

Why are analytics so important for sites based on WordPress?  

Well, if analytics are put to effective use, they can prove valuable for the website. The key areas in which analytics help are: 

1. Content Marketing 

Once you take into consideration the popular blog posts, products, pages, and content of the site, it is easy to determine what visitors love most. To get increased pageviews and traffic, it is important to create blog posts or content that echoes well with the audience. 

2. Inbound Marketing 

Knowing from where traffic is coming helps to determine which marketing strategies are working and which are not doing well, Accordingly, money and efforts can be placed on those strategies that are producing improved results. 

3. Auditing User Experience 

The user behavior rightly points out the problems that a site might be having. It might be related to the site’s design or navigation. Basically, analytics point out the poorly performing content or pages with high bounce rates that need to be worked upon. 

4. Audience Segmentation 

The key to communicating with the audience is to understand them in the first place. This will eventually help with conversion.  

In fact, with the help of GA, subgroups for targeted marketing can be created. The conversion report is helpful for eCommerce sites. It helps to track down sales and revenue.  

The various reports that GA offers help businesses gain a true understanding of where the site is standing. Plus, they help one to fix the problem areas by implementing the best marketing techniques for the site.  

With the right technique, a site is bound to get increased traffic, revenue, and even conversions. 

Now, it is time to investigate the ways that allow adding Google Analytics to WordPress. 

Add Google Analytics to WordPress & Improve the Website’s Performance 

If you have a WordPress site and want to improve its performance, then there is a way to do that. You must use Google Analytics. 

One needs to remember that a site’s performance can be improved only when the user experience improves across different devices. Also, the underperforming traffic sources must be optimized. An improved content strategy can help a site get more traffic and eventually perform better. 

Hence, without any second thoughts, you must make it a point to add GA to your WordPress site. It will help to track the performance of the marketing campaigns and even improve the site’s performance.  

However, adding GA to a WordPress site is an overwhelming task. Fortunately, there are many ways to add Google Analytics to a WordPress site.  

In the latter part of this blog post, you will get to know the ways to connect GA to a WordPress site with a plugin and without it. Both ways will be discussed in this blog post. 

But before adding Google Analytics to any WP site, let us understand why analytics are so important for any WordPress site. 

Things That can be Tracked by Adding Google Analytics to WordPress 

There is no denying that GA not only helps to track down the activity of the visitors, but also tells the length of their stay on the page or the site.  

With Google Analytics installed on WordPress, it is easy to obtain any type of report from Google Analytics. So, let us look at the type of reports that one can get from the GA tool. 

1. Real-Time Activity 

Business owners often look forward to real-time reports for understanding the user’s activity on websites. For instance, these reports can show the actions of the visitors once they visit the site. Or they can pinpoint the channels that are pulling the customers to the site. Basically, this real-time report monitors the recent results from a campaign or a social-media post. 

2. Engagement 

Engagement reports offer a clear understanding of how any user is interacting with a website. This includes page views, time-on-page, scrolling activity, interaction on social media platforms, and more. 

GA groups the user activity based on sessions. Also, this report helps to track down the conversion rate. Depending on the result, a comparison can be made with the business goals. Also, it gives a clear understanding of the CTAs that are working for the landing pages of the site. 

3. Acquisition 

The acquisition report is a report that tells from where the visitors come. This information is crucial when one needs to set up a marketing campaign. With the acquired information, it is easy to learn which strategy is working to obtain visitors. 

4. Demographics 

Basically, the demographics report helps to understand the target visitors. It helps to point out the age group, location, language, gender, and the topic of interest of the visitors visiting the site. 

5. Monetization 

The monetization report helps track the revenue from subscriptions, purchases, and advertisements on the site. Moreover, it shows the way a user navigates the checkout process and the way any user engages with the product pages. 

6. Retention 

This report usually monitors how beautifully a site is retaining its visitors. To put it simply, it tells if any user is returning to the site after their first visit and for how long they are staying on the site. 

7. Tech 

This report shows the technology that is mostly used by visitors for accessing a site. In simple words, this report includes details regarding the accessing application and device category. Accessing applications includes a web browser and mobile application, whereas the device category includes mobile, desktop, or tablet. 

How to Add Google Analytics to WordPress 

Do you want to add Google Analytics to your WordPress site?  Yeah!  

There are many ways to add GA to a site. They are: 

  • Using Google Analytics WordPress Plugin 
  • Manually connect Google Analytics and WordPress with a code 
  • Integrate Google Analytics and WordPress with Google Tag Manager 
  • Synchronizing Google Analytics Locally for performance improvements 

So, if you are keen on learning the ways, you need to go through the remainder of this post. 

But before connecting Google Analytics to your site, make sure to set up a Google Analytics account. Only after the account has been set up can it be added to the WordPress site. 

Setting Up Google Analytics Account 

Make sure to get your Google Analytics setup ready. Once it is ready, you will get the tracking code that can be added to the WP site. 

Primarily, log into your Google account. In case you do not have an account, simply create one. 

Secondly, head to the Google Analytics section and click on the Setup button to initiate the process. 

On the ‘Create Account’ page, you will be required to enter details like an account name. It can be a personal name or a website name. 

Next, you will need to select the Account Data Sharing Settings and click on Next. 

Thirdly, you will need to choose a way through which you want to measure the site. You can click on ‘Web’ option. After that, you can proceed to the Next page. 

At this point, you will need to provide website details, including URL, industry category, name, and time zone. Once you have filled in the details, click on the ‘Create’ button. Now, a pop-up window containing ‘Terms of Service’ will appear. Quickly go through it and click on the ‘I also Accept’ checkbox. 

Now you are done with the Account setup. 

From here, the main task will start, i.e., installing GA on WordPress. 

Different Ways to Install or Add Google Analytics to WordPress 

As you might know, Google Analytics can be installed on WordPress in diverse ways. But the most popular ones are: 

  • Adding Google Analytics using a Plugin  
  • Adding Google Analytics manually 

Let us delve deep into the details. 

Method 1: Adding Google Analytics to WordPress Via a Plugin 

One of the easiest ways to add GA to any WordPress site is to use a WordPress plugin. This method not only saves time but also saves you from the hassles of editing the website’s code. Plus, it is also safe as it will not mess with the theme. 

In case you are considering using a plugin for any WordPress site, you are free to use any type of plugin, such as MonsterInsights, GA Google Analytics, Header/Footer Script Plugin, and more. 

Before using any plugin, the first thing that you will need to do is to install the plugin on the WordPress site. Once it is successfully installed, one can put in the tracking code. 

Still confused over the entire process of using a plugin? Let us take you through the steps. After that, you can learn about the suitable plugins that help to add Google Analytics to a WordPress site. 

Step 1: Install the Plugin 

To do this step, navigate to the Plugins section in WordPress backend and click on Add New. Once you have clicked on Add Plugins, write the name of the plugin that you want to use in the search bar. 

From the result list, pick the preferred plugin and click on Install. This will start downloading the plugin on the site.  

Step 2: Activate the Plugin 

Once the plugin is installed, simply click on the Activate button. This step will activate the plugin, and it will analyze the process. 

Step 3: Input the Tracking Code 

Once the plugin is installed, it needs to be configured. The configuring option will come under Settings. From Settings, one will need to click on Plugin Setting for opening the settings window. 

Once the window opens, the next thing that one needs to do is to insert or put the Google Analytics Tracking ID.  

Fetching the GA Tracking ID is extremely easy. Head to the Google Analytics account and select the Admin menu from the left bottom corner. Next, one will need to click on the Property and Tracking Info menu.  

From Tracking Info, one will be able to get the Tracking Code. At this point, one will need to copy the ID only, but copying the code and saving it is also a clever idea.  

Once the code is obtained and copied, one can head back to the Plugin Settings on WordPress and insert the ID in the top right corner of the plugin settings. A blank field with GA Tracking ID will appear. This is where one will need to put in the ID and pick the correct tracking method.  

Step 4: Configure the Plugin 

Once the Tracking ID is inserted, it is time to set up the plugins by moving to the settings. One needs to keep in mind that only a few settings are available for some types of Google tracking codes. 

4.1 Link Attribution

The enhanced Link Attribution feature allows tracking down the link to the same URL that a user clicks for a single page. 

4.2 Force SSL

This allows sending all data via secure HTTPS connections, even if the site has not moved to HTTPS. 

4.3 Display Advertising

This allows Google Analytics data for the Google Display network. 

4.4 IP Anonymization

Checking on this box will enable IP anonymization. It is ideal for all those who need to follow the new GDPR rule. 

4.5 Custom Tracker Objects

This allows the user to add code and eventually collect the custom data. 

4.6 Tracking Code Location

It helps to determine whether the tracking code should be loaded in the header or on the footer page. Google suggests adding the code on the header but using the footer will not impact the page performance. 

4.7 Admin Area

By enabling the Admin Area, it helps to include the user behavior in the WordPress admin section of the GA data. 

4.8 Custom Code

In the event of any markup that needs to be executed along with the tracking code, it can be placed here. 

4.9 Custom GA Code

This lets you add any custom code that needs to be present within the Google Analytics tracker. 

4.10 Custom Code Location

This option defines whether any custom code needs to be executed before or after the Google Analytics tracker. By default, it is set to after the GA tracker.  

After everything gets configured as per the likings, it is important to save the changes. Only then will the implementations come into effect.  

Congratulations! You are now aware of how to add Google Analytics to WordPress with a plugin. 

Method 2: Adding Google Analytics to WordPress Manually  

If you are planning to add Google Analytics to WordPress manually, then there are two ways to do that. But before you get started make sure you have the Google Analytics tracking code with you. 

To get the GA tracking code, open the Google Analytics account and select the website for which you need the tracking code. Then you should click on the Admin present in the bottom-left corner. Next, you should click on the Tracking Info and then the Tracking Code. 

Once you get the code, you can head back to the WordPress dashboard and click on Appearance. From there you will get the Theme Editor. 

Way 1: Adding GA Tracking Code to header.php File 

An effortless way to insert Google Analytics into WordPress is to add the tracking code to the header file. Why is it so? 

Doing that will allow the tracking code to get loaded for every single page. This is especially helpful if the WordPress theme is making use of the standard header.php file. 

However, as you are going the manual route, it is better to implement the code in the child theme. Doing so will prevent the tracking code from getting overwritten each time the WordPress theme receives an update. 

So, to add the Google Analytics tracking code to the Theme Header (header.php) file, you must follow these steps. 

  • Head to the Theme Editor from the WordPress dashboard. This section will appear under the Appearance menu. 
  • Click and open the Theme Header (header.php) file from the right-hand column. 
  • Simply paste the code snippet within the header area. Or to be more specific, it should be pasted above the header </head> tag. 
  • Once it is inserted, simply click on the ‘Update File’, and save the changes. 

Way 2: Adding GA Tracking Code Using functions.php 

Another effortless way to add the Google Analytics tracking code to any WordPress site without a plugin is by pasting it on the functions.php file. Remember, adding it to the footer will not slow down the site. 

WordPress is based on the PHP programming language. To insert the code, first, you need to edit the functions.php file. 

It is recommended to create a new function that will contain the code snippet. The steps involved are: 

  • Open the WordPress dashboard and head to the Theme Editor section. 
  • Simply open the Theme Function (function.php) file on the right-side column. 
  • Add the code snippet to the file. Also, replace the old Tracking ID with the new one. 
  • On completion, simply click on the ‘Update File’ button to save the changes. 

Way 3: Adding the Tracking Code with Google Tag Manager (GTM) 

Another way to add Google Analytics to a WordPress site is by using Google Tag Manager. This is ideal for sites that include scripts for a variety of reasons and not only for analytics. 

One must remember that Google Tag Manager or GTM is a tag management system that allows any user to update the code snippets and tags of a site or any mobile app that are designed for marketing optimization or for traffic analysis. 

You can easily add and update the scripts from the Tag Manager user interface, rather than editing the site code in WordPress. This kind of move will reduce the errors and there will not be any need to assign a developer while configuring the tags. 

But before you go ahead and add the tracking code using GTM, make sure you have a Google Analytics account. 

The steps to add GA through Google Tag Manager are as follows: 

Step 1 

First, you will need to sign up for Google Tag Manager. While signing up, do accept the service agreement. Also, select Web as the Target Platform and then click on Create. 

Step 2 

Secondly, you must copy the code before installing Google Tag Manager on the website. 

Step 3 

To install the GTM plugin, just visit the WordPress repository.  

Step 4 

Thirdly, paste the first code after the <head> tag and before the </head> tag. It will be ideal if you paste the tag immediately after the <head> tag. In the same manner, copy another code and paste it into the <body> tag of the WordPress dashboard.  

Step 5 

Once the codes are pasted into the WordPress Theme Editor, click on the Update button. 

Step 6 

Now, you just open Google Tag Manager and navigate to the main screen. 

Step 7 

Next, click on ‘Add a new tag’. In the new window, you will need to set a name for the tag, like the website name. Setting up a tag can help the Tag Manager to create the trigger to get fired whenever a page receives a hit. 

Step 8 

Now you will need to configure the Tag as well as the Trigger in GTM. This will help you to add Google Analytics to the site. Within the tag type, choose ‘Google Analytics: Universal Analytics.’  

The track type can be left as Pageview and then change the Settings of Google Analytics from the drop-down menu to New Variable. Once New Variable is selected, a new window will pop up that will ask you to place the Tracking ID. 

Step 9 

Copy and paste the Google tracking ID in the respective field. Once you are done, scroll down to Triggering and eventually configure the trigger.  

In another window, the tag remains pre-selected as ‘All Pages’. Simply click on it and save the changes made to the tag manager. This will enable Google Analytics in WordPress. 

Make sure to submit the changes made to Google Analytics so that it works properly. To ensure the tag assigned for the GA is working fine, click on the Preview button present in the top right corner of the dashboard. Add the website URL in the pop-up and click on the Start button. This will make sure that the tag on the site is firing properly. 

If you are not willing to use any plugin that integrates with Google Analytics, then simply add the tracking code on the site’s header or footer area. Manually inserting the code into a WordPress site is always the best bet for any WordPress user because it is easy to follow and implement. 

Now that you are aware of these methods, you must be wondering which method would be the right one for adding Google Analytics to your WordPress. The answer to this query is obviously a personal choice, but using a plugin is sometimes considered the best option. 

Types of Plugins That can be Used for WordPress Sites 

Wondering about the GA plugins that are ideal for WordPress sites? Nothing to worry about as there are tons of plugins to pick from. Follow this blog post to learn more about the popular options. 

1. MonsterInsights 

This is a robust plugin for the Google Analytics dashboard and perfectly designed for meeting any marketing needs. The best part of this plugin is that it allows you to create customized reports based on the preferred parameters. 

Two versions of this plugin are available. One is the free version, and the other one is the paid or Plus version. The paid version is ideal for small businesses. Now, let us come to the process of adding GA by using the plugin MonsterInsights

First, from the WordPress dashboard, head to Plugins and click Add New. 

Next, search for Google Analytics Dashboard Plugin for WordPress by MonsterInsights. Once you come across the plugin, download, and activate the plugin. 

Head back to the WordPress dashboard again. You will come across a new Insights option. 

Now, you must scroll down a little to come across the Launch the Wizard button. Click on the Launch button and follow the instructions to complete the setup process. At this point, you will need to Connect the MonsterInsights plugin with your Google Analytics account. 

Here, you will need to click on Allow which will give this plugin permission to view and manage GA data, edit GA management entities, view AdSense data, and more. Follow all the instructions and fill in the required information. Once done, click on the Finish Setup & Exit button. 

Once you click on the Exit button, the plugin integration process is fully complete. Now, you can simply visit the Insights menu and click on Reports to view a site’s performance. 

2. Insert Headers and Footers 

Another popular plugin that can be used for the WordPress dashboard is the Insert Headers and Footers plugin.  

To install this plugin, one should head to the WP dashboard and search for this plugin in the search bar. 

Once you come across the plugin, click on Install Now. After it gets installed, you must activate it. 

After the plugin is active, make sure to copy and paste the tracking code. For pasting the code, first, copy the code from the GA dashboard. Then head to the Insert Headers and Footers plugin from the Settings tab of the WordPress dashboard. 

Once you click on Insert Headers and Footers > Settings, a separate window will pop up. On this window, you will need to paste the code inside the box titled Scripts in Header. After you paste the code, you are ready to go. 

3. CAOS 

Another plugin ideal for WordPress sites is CAOS. CAOS stands for Complete Analytics Optimization Suite. This plugin is available within the WordPress plugin repository. 

To integrate this plugin within WordPress, the following steps must be followed. 

Firstly, download and install the plugin. 

Secondly, activate this plugin.  

Once activated, you can add Google Analytics to the plugin. For integrating the GA, head to the Basic Settings and paste the Google Analytics Tracking ID. 

Once you save the plugin, it will fetch the code automatically. The best part is that one can decide where the tracking code should be placed, i.e., in the header or in the footer. 

Add Google Analytics to WordPress Using a Plugin: Is it the Best Choice? 

The method of adding Google Analytics to WordPress using a plugin seems to be the best way out. However, one can add Google Analytics to WordPress sites even manually. Both ways come with their own set of benefits.  

Yes, you heard that right! In case you are wondering which method to opt for, first understand the benefits. So, read on. 

Why is Adding Google Analytics to WordPress Via a Plugin Beneficial? 

  • When you plan to add Google Analytics to WordPress with a plugin, the process becomes fast, easy, and hassle-free. 
  • Using a plugin allows the user to set up the features automatically, saving one’s time. 

Is Adding Google Analytics to WordPress Manually Beneficial? 

Some WordPress owners might consider adding Google Analytics to WordPress without the use of a plugin. They prefer to do the job manually. The reasons are: 

  • Firstly, most WordPress site owners are concerned with the fact that using too many plugins that are not optimized might slow down the WordPress site. 
  • Secondly, the price of using a Google Analytics plugin is also a concern for many. Even though using a Pro or Paid version is much better than a Free version, the free versions can also run well. 
  • Thirdly, some website owners are aware of the process of installing the Google Analytics code. Hence, they do not want to install the plugin. 

Google Analytics and GDPR 

Before adding Google Analytics to the WordPress site, make sure you are aware of Google Analytics and GDPR rules. 

Most of you might be aware that a new European rule on consumer data protection came into effect. This is known as General Data Protection Regulation (GDPR).  

This law will have consequences for those active in the European market. So, one should ensure that their use of GA is completely compliant with the GDPR. 

1. Do Not Send Any Personal Identifiable Information (PII) 

Things like email, phone numbers, and home addresses are often used for personally identifying someone. It is important to audit the site in case you are sending these types of data to Google. 

2. Enable IP Anonymization  

PII can even extend to IP addresses. For this reason, switching to anonymization within Google Analytics makes some sense.  

3. Include Privacy Policy 

As per the new law, a website should have its own privacy policy. The document needs to be written down in simple language and it should cover everything, starting from everything you do regarding collecting and processing user data, including cookies, contact forms, and more. 

4. Cookie Consent Should be GCPR Compliant 

There is no need to take consent from users for cookies that are not necessarily required. The consent solution must contain the purpose of the cookies. Also, ensure visitors that they can browse the site even after declining the cookies. Visitors should be able to access the cookie settings and document everything. 

Concluding Thoughts 

If you have a WordPress site, then there is a high need to add Google Analytics. It is not that WordPress will cease to exist without Google Analytics but adding Google Analytics on WordPress helps to bring traffic and offer valuable insights about visitors. 

It is important to keep in mind that there are several ways to add Google Analytics to WordPress. Whatever method you chose for installing the GA tracking code, make it a point to take the help of eWay Corp professionals. Being industry experts, they can install the GA on your WordPress site without affecting the theme or disturbing the code. Contact us today.