Winter Special Sale! Unlock a 20% OFF on Bundle of 240+ WP Themes & 5 Plugins. Use code "SNOW20"
This Winter, Enjoy a cozy 25% discount on Premium WordPress Themes with the coupon code "WINTER25" at Checkout.

Step by Step Guide to Set Up Google Analytics in WordPress 2023

how to add google analytics to wordpress

Are you curious about the different actions your users perform while visiting your site? If so, then Google offers you several tools to understand these activities. Among them, Google Analytics is a famously known tool. From tracking your website’s visitors to analyzing vital data, there is a lot you can do. Moreover, it is a free tool that is available for you to use.

What Is Google Analytics?

Google Analytics is a Web Analytics Suite that actually helps the users to understand and analyze the web traffic of their websites. It tracks the different activities associated with the website and show in the form of statistics in Google Analytics account.

From Google Analytics website owner come to know about visitors to our websites. Get details about which segment of users are visitors to your websites, how the visitors interact with the available content in the website, what they are doing with the content and how they are interacting with your website. This information helps website owners to understand the flaws and can direct them to optimize content.

If you are thinking of how to add Google Analytics to WordPress, we are here to help you with step by step guide on adding Google Analytics to your WordPress site. These include creating an account, obtaining and adding a tracking code using numerous methods, and checking if the code is working. Without wasting time, let us get into it.

How to Create a Google Analytics Account

Even if you lack a technical background, installing Google Analytics on your WordPress site will be a breeze. You can easily for the demonstrated steps. So, the first step is signing up for Google Analytics account. Signing Up for the Google Analytics is so simple. All you need is Google Account for it. If you don’t have one, just make it.

Steps to Sign Up and Creating Google Analytics Account

If you possess an existing Google account, you can start by entering your login details. If you do not have an existing account, you must initiate by clicking on the option “Create account”. After entering your details regarding your name, password, email, contact number, etc., and creating a Google account, visit the homepage for Google Analytics.

Let us go over each step to help break down the process:

  • Once you navigate to the homepage of Google Analytics, select the blue button saying, “Start measuring”.
  • You will find yourself on the page for Account setup.
  • Enter your account name in the space for “My New Account Name” and check the options for “Account Data Sharing”.
  • Select “Next”.
  • The second step is Property Setup. It will help you select the reporting name, currency, and time zone.
  • Enter the necessary information and select “Next”.
  • Next is the form for “About your business”. You will have to check the options for business size, the aim of using Google Analytics for your business, and the industry category.
  • Upon selecting “Create”, “Google Analytics Terms of Service Agreement” will pop up. Select “I Accept” after to say you agree with their terms. Doing so will create a Google Analytics account.
  • In “Data Streams”, select the platform of your preference. For a WordPress site, select the “Web” option.
  • To “Set up your web stream”, enter your “Website URL” and “Stream Name” and then select the “Create Stream” option. 
  • The “Web stream details” will display that you have successfully created a web stream. However, this does not mean that data collection is active. For this purpose, you must install “Google Tag”.
  • For adding “Google Tag”, select “View tag instructions”. This will give you two options to “install with a website builder or CMS” or “install manually”. Upon adding the tag, Google will begin data tracking to the dashboard of your Google Analytics account. 

This was all about creating an account. Now let us learn about the next step for adding Google Analytics to WordPress, i.e., obtaining tracking code.

Obtain Tracking Code

If you wish to know everything regarding your website and track the behavior of your visitors, you can add Google Analytics to your WordPress site. But to do this, you will first need to obtain a tracking code. But what is a tracking code?

When we talk about web analytics, a JavaScript code snippet refers to as a tracking code. It can track your website visitor’s activity. Whenever a visitor comes to your website, the tracking code records how the visitor engages with the site or web page in the form of pseudonymous information.

A tracking code can also collect data regarding the user’s browser type, language settings, device, and OS. It is the tracking code that lets you know what directed the visitors to your site, such as a web browser, email, advertisements, etc.

Generally, you will find two variations for the Google Analytics tracking code. These are UA or Google Universal Analytics and GA4 or Google Analytics 4. GA4 offers more adjustment options. The GA4 is for applications and websites, whereas UA works only with websites.

To find the tracking code or ID for your Google Analytics, you can do as follows:

For UA:

  • Go to the account you created for Google Analytics.
  • In your navigation sidebar, click on “Admin”.
  • From the second column, click “Tracking Info”> “Tracking Code”.
  • You will be able to see your tracking code on the right side of the new screen.

Add Tracking Code to WordPress

The next question is how to add Google Analytics code in WordPress. You can use four ways to add the tracking code to your website.

1. Adding tag code to the header.php

It is possible to install Google Analytics to your WordPress site by copying and pasting the tracking code to your header.php file. You can do this as follows:

  • Visit your WordPress site’s Dashboard.
  • Go to “Appearance” and navigate to “Editor”.
  • Select the file with “header.php” for editing the code.
  • Next, from your Google Analytics, copy the “Tracking Code”.
  • In your header.php file’s code, paste the tracking coder before the tag for <head>.
  • When completed, the installation can take up to 48 hours for a complete activation.

2. WordPress Plugin for Installing Google Analytics 

To install Google Analytics, the simplest alternative is WordPress plugins. You may use this option in case the first method is not possible because of your theme. For this purpose, you will have to install a WordPress plugin for Google Analytics. There are several solutions available for WordPress plugins. Some of these include:

GA Google Analytics:

A robust and well-coded plugin for your website is GA Google Analytics. To install this plugin, you must:

  • Visit your Dashboard on WordPress.
  • From here, navigate to “Plugins” and select “Add New”.
  • Search for “GA Google Analytics” and “Install Now”.
  • Finally, “Activate” it and configure it.
  • Revisit the Dashboard, and in “Settings”, select “Google Analytics”.
  • Go to “Plugins Settings” and paste your “Tracking ID”.
  • Check the boxes for “Universal Analytics” and “Include tracking code in page head”. These options will set up your Google Analytics on your site.
MonsterInsights:

Another popular WordPress plugin for Google Analytics is MonsterInsigts. It is a popular choice among its users, given its user-friendliness. To install this plugin, follow the same steps as before. After activation, you can move to the plugin settings to link it with your account.

Next, follow the given steps:

  • Select the “Connect MonsterInsights & Setup Web Analytics” options to run the setup for this plugin.
  • Choose the best category for your website.
  • You will not need a license unless you are using a pro version.
  • The next step is to connect and authenticate your account with the plugin.
  • Once done, select “Save & Continue”.
  • The plugin will require some time to fetch information and showcase the live tracking in your dashboard after completing the setup.

3. Google Tag Manager for Adding Google Analytics

When you are thinking of how to add Google Analytics to WordPress, you cannot miss this method of using GTA or Google Tag Manager.

  • After visiting your dashboard, select “Plugins” and “Add New”.
  • In the search field, enter “Google Tag Manager”.
  • Install > Activate
  • Navigate to GTA and select “Create Account” to sign up.
  • Enter your details, such as container name, country, and account name and select “Create”.
  •  
  • After signing up, you will find the GTA snippets.
  • Select “Ok” and get the “Google Tag Manager ID”.
  • Finally, paste your ID in the plugin’s setting and “Save Changes” to successfully add Google Analytics.

4. Local Hosting

Lastly, if none of the above methods works for you, you can use local hosting. To reduce HTTP requests and better performance, you can choose to locally host your Google Analytics. You can use a lightweight WordPress plugin for this, such as CAOS or a complete analytics optimization suite.

  • Head to the dashboard, select “Plugins”, and find CAOS.
  • After the plugin installation and activation, visit the plugin’s settings.
  • Paste your Google Analytics Code and choose a location for placing your tracking script.

Verify Google Analytics Is Working

If you have completed your GA integration with your site, the following step involves verifying whether your GA is working efficiently or not. Firstly, after the completion of setup and placing your Analytics tag, give it 15-30 minutes.

Next, you can verify your Google Analytics working by following these steps:

  • Visit your Google Analytics account.
  • Select “Realtime” and open “Overview”.
  • Go to any WordPress site page.
  • If the GA is working efficiently, a bar will be visible to show the data of your WordPress site goes well in the GA.

Some common issues arise when tracking data for your WordPress site in your GA. These include:

No traffic: If your website lacks traffic, no data will be visible on your GA reports. For this, you can try interacting with your site and check whether the “Realtime” report displays this activity. 

No data processing: For first-time installers, GA takes around 24 hours to process your website data. In addition, if your website lacks users, GA can apply thresholds to keep your user’s identity safe. You can check for these thresholds.

Conclusion

Google Analytics is vital for your website as it gives you an insight into its performance. It allows tracking your users and how they interact with your website. You can better understand your website visitors and develop better strategies for marketing and website customization.

To add your GA to your WordPress, you will first have to create an account on Google Analytics. Then find and add tracking code to your WordPress. For adding code, you can use different methods, including plugins, GTA, header.php and local hosting. Once completed, verify the successful working of your Google Analytics.

If you want to get the best from your website data and enhance your KPIs, you must evaluate your audience based on their age and gender and create targeted content. Put your conversions on top and measure them to link them to your website content’s success. You can also do many other things to ensure your website works efficiently.

FAQs on Adding Google Analytics to WordPress

Can I use Google Analytics to track multiple websites?

Yes, it is possible to keep track of numerous sites using one account and adding them to Google Analytics. To do this, you can use two ways. The first method involves adding all the sites as separate properties under one account. The second method involves adding a special Analytics ID to separate websites.

What are the benefits of using Google Analytics on a Website?

Website owners can enjoy a range of benefits with Google Analytics. It works towards supporting your website’s SEO optimization and helps track how well your efforts work. It allows you to compare traffic for various keywords and build better marketing campaigns.

In addition to this, it allows website optimization to reduce bounce rates. You will get the option to shift to a specific location that is imperative to your business. As a result, you can get to know your prospects better. Google Analytics also enable you to distinguish your users depending on their location, visiting frequency, and referral routes. And these are only a few of the many benefits it has to offer.

What should I do if I encounter issues while adding Google Analytics to WordPress?

If you encounter any issues with your tag setup, it is imperative to troubleshoot them. These issues arise when the measurement code is not added to your site, incorrect measurement code installation, no website traffic, and no data processing. To fix issues, you can check for these problems. Additionally, you can head to support.google.com for Analytics Help.