How To Add Google Analytics 4 to WordPress (Easy Way)
Do you want to know how to add Google Analytics 4 to your WordPress site?
Learn about the two easy ways we’ve described for new and experienced users!
In this blog, we will talk about a very popular topic: how to add Google Analytics 4 (GA4) to your WordPress site. This powerful tool lets you track and analyze your website performance. This gives you valuable information that you can use to make good choices and help your website grow.
We know that not everyone has the same amount of technical knowledge, so we have given you two different ways to add GA4 to your WordPress site. Our goal is to help both new and experienced users so that everyone can take advantage of this important connection.
Table of Contents
We suggest using Analytify, the WordPress plugin, for people who want an easy solution without coding… We’ll walk you through the process step by step so that you can set up and use GA4 on your website with ease.
However, if you are good at coding and want to do things yourself, we also have explained how to manually connect GA4 without using a plugin in this guide. This method gives you more power over the process of integration and lets you make more changes.
So, it doesn’t matter if you’ve never coded or been doing it for years. Stay tuned as we go into more detail about each way and give you the information and tools you need to successfully add Google Analytics 4 to your WordPress site.
How to Add Google Analytics 4 to Your WordPress Site?
There are two ways to add Google Analytic 4 to your WordPress site.
- One way to add is through a WordPress Plugin, Analytify. This is the best option if you don’t know coding or you want a smooth and hassle-free integration.
- The other way to add is without a WordPress Plugin. It’s good if you know coding.
I. Add Google Analytics to your WordPress Site through Analytify
Analytify is the best WordPress plugin that makes it easier to add Google Analytics to a WordPress site. Follow these steps to get going:
Note: If you’ve already set up the GA4 property, you can skip the next steps and move directly to Step 4.
Step 1: Sign up for Google Analytics
Visit Google Analytics and sign up with your Google account if you don’t already have a Google Analytics account.
Click Set up for free.
- Type in the details about your website that is asked for, then click Next.
- Pick Web as the platform and click Next.
- Fill in the required information about your website (URL, name, etc.) and click Create.
Step 2: Set up a GA4 Property
If you haven’t made a GA4 property yet, you’ll need to create one. Follow the below steps.
In your Google Analytics account, go to the bottom left area and click the Admin button.
Choose the account you want to use from the Account section.
Click the Create property. See the below picture to follow these steps.
Fill in the property Name and click on Next. It can be the name of your website or business.
Fill in Business Information and click on Create.
After clicking Create, you’ll be redirected to the Data Stream page.
Choose your platform for the data stream. In our case, we choose Web as the platform.
Step 3: Set Up the Data Stream
Type in the information about your website (URL, name, etc.) and then click Create.
Click the Web on the Data Streams page. You’ll be navigated to Web Stream Page.
See Installation Instructions by clicking on View Tag Instructions.
Install it with Analytify.
Step 4: Install Analytify, the WordPress Plugin, and Turn It On
First, go to your account in WordPress. Then, click Plugins>>Add New.
You’ll be navigated to a new page. Type Analytify into the search bar to find it, as shown in the picture below.
Find the Google Analytics Dashboard Plugin for WordPress by Analytify in the search results, then click Install Now and Activate when the installation is done.
Step 5: Install and Activate Analytify Pro
Google Analytics Dashboard Plugin for WordPress by Analytify is a free version of Analytify, which is limited.
However, to use all the useful features, you have to purchase Analytify Pro. For this, simply click on Analytify.
For an in-detail guide, read How to Install And Activate Analytify Pro Plugin.
After purchase, you would be provided with license keys and add-ons. You can download these add-ons, as shown in the picture below.
After downloading these add-ons, again go back to your WordPress site and add these add-ons by navigating to Plugins>>Add New>>Upload Plugin>>Install Plugin.
After installing the Plugin, you’d need to activate it. Do this step for all add-ons.
Step 5: Connect Analytify to Google Analytics
Get the license keys from the analytify account from where you purchased Analytify add-ons.
Now, go to Analytify>>Settings on your WordPress homepage.
Click the License tab and add license keys.
After adding the license keys of all add-ons, navigate to the Authentication tab.
Click the button that says Log in with your Google Account to link the app to your Google Analytics account.
You’ll be navigated to the next page. There, choose an account to continue with Analytify.
When asked, give the rights that are needed. And click on Allow, as shown in the picture below.
Once you’ve connected properly, you’ll be navigated back to the Analytify settings page. Then, from the dropdown menu, click on the Profile tab and choose the Google Analytics profile (property) you want to use for your WordPress site, then click on Save Changes.
Step 6: Set up More Settings
Now that the basic setup is done, you can look at the other settings tabs in the Analytify plugin to set up more choices, like preventing certain user roles from being tracked or allowing for better eCommerce tracking.
Step 7: Check to See If Google Analytics is Working
Visit your website in a new browser or private window, and then go back to your Google Analytics account. See if your visit is being tracked by looking at the Realtime Report. If everything is set up right, at least one person should be shown as a visitor in the data.
You can also verify this in your WordPress Dashboard by navigating to Analytify>>Dashboards.
All done! With the help of the Analytify tool, you have successfully added Google Analytics to your WordPress site. You can now track your website’s traffic, user behavior, and other important metrics straight from your WordPress dashboard or through the Google Analytics platform.
II. Add Google Analytics to a WordPress Website Without Plugin
There are various methods to add Google Analytics to a WordPress website. But I found the following 2 to be the easiest and quick for beginners.
Method 1: Integrate Google Analytics and WordPress Manually with Code
(Don’t worry. You only need to copy-paste the code)
If you don’t want to use a plugin, you can follow these steps to directly add the GA4 tracking code to your WordPress site:
Step 1: Get the GA4 code for Tracking
Sign in to your Google Analytics account.
Click the Admin tab in the bottom-left area.
Choose the account you want to use in the Account section.
Choose the GA4 property you made for your WordPress site in the Property field.
Click Data Streams in the Property box.
Follow the below picture:
Pick the Web data stream that is connected to your website. Click on the data stream. You’ll be navigated to Webstream details and Tag Instructions
Click on View Tag instructions and scroll down the page.
Click on Install Manually and copy the code given for tracking.
Step 2: Add the Tracking Code to Your WordPress Site
Open your WordPress homepage by logging in.
If you don’t have installed Insert Headers And Footers plugin, you would first need to add this Plugin.
For this, navigate to Plugins>>Add New and write Insert Headers And Footer in the search bar. Install this Plugin. Follow the image below.
Now, under the Tools, navigate to Settings>>WP Headers and Footers.
In the Scripts in the Header part, paste the whole tracking code that you copied from Google Analytics.
Then, scroll down the page and click Save to keep the changes you’ve made.
Now, the Google Analytics 4 tracking code has been successfully added to your WordPress site by using the Insert Headers and Footers tool. It will keep track of what people do on your website and tell your Google Analytics account about it.
Step 3: Make Sure the Link Works
Open a new tab or window on your computer and go to your site.
Go back to your Google Analytics account and click on Realtime in the menu on the left.
Look to see if your visit is in the report. If it is, the link is set up right.
Method 2: Add Google Analytics to WordPress with Google Tag Manager
Adding GA4 on your WordPress site with Google Tag Manager (GTM) is a good way to keep track of various tracking codes in one place. Here is a step-by-step guide for setting up GA4 with GTM:
Step 1: Make an Account for Google Tag Manager
Go to Google Tag Manager and use your Google account to sign in. If you don’t already have a GTM account, click Create Account and fill out the information asked for.
Set up a new container for your website by giving it a name and selecting Web as the platform to target.
Click Create and agree to the service terms.
You will be given the GTM as shown in the picture below.
This GTM tab will appear itself. If you accidentally remove this tab, you can navigate to Admin>>Install Google Tag Manager.
After clicking on Install Google Tag Manager, you’ll be navigated to the Google Tag Manager Tab.
Copy both tags to add into WordPress site.
Step 2: Add the Tracking Code to Your WordPress Theme
Open your WordPress homepage by logging in.
If you don’t have installed Insert Headers And Footers plugin, you would first need to add this Plugin.
For this, navigate to Plugins>>Add New and write Insert Headers And Footer in the search bar. Install this Plugin. Follow the image below.
Under the Tools, navigate to Settings>>WP Headers and Footers.
In the Scripts in the Header part, paste the whole tracking code that you copied from Google Analytics.
Scroll down the page and click Save to keep the changes you’ve made.
Copy and paste the first part of the GTM container code, which is inside the <head> tags in the box of Script in Header.
Copy and paste the second part of the GTM container code, which is inside the <body> tags in the Script in the Body box.
Scroll down the page and click Save to keep the changes you’ve made.
Step 3: Set up the GA4 tag in GTM
Open your Google Tag Manager account again.
Click Tags in the menu on the left and then New.
Give your tag a name, such as GA4 testing Tag, and click Tag Configuration.
Pick Google Analytics: GA4 Configuration from the list of tag types.
In the Measurement ID field, put your GA4 property’s Measurement ID (G-XXXXXXXXXX).
You can find this ID in your Google Analytics account by clicking Admin, then Data Streams, and then choosing the data stream.
Click on Triggering and choose All Pages, which is the usual Page View trigger. This makes sure that the GA4 tag works on all of your website’s pages. Click Save to finish setting up the tag.
Step 4: Publish the GTM Container
Click Submit in the top right corner of your GTM account.
Give it a name and a description, and then click Publish. This will make your page show your GA4 tag.
Step 5: Make Sure the Connection Works
Open a new tab or window on your computer and go to your site.
Go back to your Google Analytics account and click on Realtime in the menu on the left.
Look to see if your visit is in the report. If it is, the link is set up right.
Wrapping Up
Adding Google Analytics 4 to your WordPress site is a must if you want to know your audience, track how well your site is doing, and make growth decisions based on data. We looked at two different ways to help people with different levels of skill: the Analytify Plugin for those who want a simple solution that doesn’t require coding and a manual integration choice for those who know how to code and want more control over the process.
No matter which method you choose, the key is to use GA4‘s power to improve the user experience on your website, increase engagement, and eventually drive success. We hope that our detailed guide has been helpful in knowing how to add Google Analytics 4 to your WordPress site. Stay tuned for more tips, tricks, and insights on how to improve your online business, and don’t be afraid to share your experiences or ask questions in the comments section.
We hope this guide was helpful in setting up Google Analytics in WordPress. It is very helpful for marketers and business owners to track and monitor their website performance.
That’s all! You can also check out All About Google Analytics Events vs. Goals (Simple Guide) and How to Use Google Analytics to Increase Website Traffic.
Not using Analytify yet? What are you waiting for?
Frequently Asked Questions
Does Google Analytics work with WordPress?
Yes, Google Analytics is compatible with WordPress. In fact, it works with almost any CMS, such as Joomla, Drupal, or Magento.
By integrating it with a plugin in your blog or business website, you can easily get the data in the WordPress dashboard.
Do I need to put Google Analytics code on every page?
No, you are not supposed to put Google Analytics code on every page of your website. All you need to do is place the code between the opening <head> and closing <head> tags of your website.
It is always advised to place it as soon as the head tag opens to ensure precise tracking of data.
Is Google Analytics a plugin?
Google Analytics is a free web and app analytics tool available to anyone. It is not offered as a WordPress plugin. However, you can easily install Google Analytics in WordPress using a plugin like Analytify.
Can you set up Google Analytics for multiple websites with the same Google account?
Yes, you can set up Google Analytics for multiple websites by going to the Google Analytics Admin section. There is an option to add a new account that would be your new site.
Any update on the Analytify plugin’s compatibility with Google Analytics GA-4?
It is already compatible with GA4 since Analytify 5.0 version.
Check out the changelog http://analytify.io/changelog/
I tried to connect Google analytics code to the wordpress using insert Header and Footer plugin. But when i verify it said “verification unsuccessful”. Please help me to solve it.
Thank you for the clear and concise instruction. Was able to get this done without yet another plugin
applied the code manually and it’s working perfectly to my website, thanks a lot for your assistance!
By any chance using the Brave browser couldn’t be a problem to see the analytics?
Hello, Tayyab, great job on creating such an amazing and informative article! I think in my opinion, Adding the analytics using a plugin is the best way as you will never lose the code when you update the theme and they also offer you a wide range of options with rich additional features.
Thank you for sharing this blog. It’s really helpful.
Hey Tayyab, I am glad that I found your blog thanks for sharing this article. I was really searching for some information like this. Thanks for sharing this blog. I got all the information that I was looking for.
You are Welcome, Priya Sharma 🙂
Hello
When I click selected Profile for posts nothing shows up, it is already difficult. I don’t know what to do to get google analytics code inside the website. Thank you very much.
That might be because you created a GA4 account instead of a UA property. GA4 accounts don’t show up in the profile drop-down because Google hasn’t updated its API yet. You need to create a Universal Analytics property.
Check this article: http://analytify.io/doc/how-to-integrate-analytify-with-google-analytics-4-ga4/
Hello Davy
Thank you so much for helping me, you have solved my problem. It is working now, the way I really need it. Thank you very much!
Hello
I have had so much trouble selecting Profile for posts, nothing shows up here, I cannot select nothing from it. In order to used google analytics I must give a code or call a code from this plugin. But it didn’t show me an option, What should I do?
Thank you in advance
Jennifer
Your blog is really good.I have learned so many things from your blog.
Hi! I just have a question, I entered the Google Analytics code in the header.php part but… wouldn’t that be erased when you update the theme?…
Nope, Only the functions.php file will be updated
Your blog is very informative.I have learned so many things about Google Analytics from your blog.
Thank you