Want to set up Google Analytics plugin for WordPress website for free? This blog post will give you everything you need to know to get started today.
Ready to grow your website? Collecting website data is the first step to analysing your website performance. Having set up GA4 for more than 20 websites, I am familiar with the RIGHT way to collect data on the website and will be bringing you through the EXACT steps.
You will learn all about the basics of data collection, how to set up the Google Analytics plugin for WordPress website, quality assessment methods, GA4 setup, and conducting quality checks on data.
By the end of the post, you will be equipped with all the knowledge and skills you need to start collecting your website data today.
This post is all about setting up a free Google Analytics Plugin for WordPress websites.
Basics of Data Collection
Whether you are building your blog from scratch or using platforms like Wix, Shopify, or WordPress, the fundamentals of typical data collection remain the same.
A basic website consists of 2 main components – HTML and CSS. To collect data effectively, we must insert codes into the website’s HTML, often referred to as a data layer. This method ensures the most sustainable data collection.
Now, you might have heard about the “easy-to-use” settings on Wix, Shopify, and WordPress, where you can simply copy and paste your GTM ID or GA4 Measurement ID, and voilà, your data appears in GA4.
However, let me explain why this is NOT the best approach:
- It is like a black box – you lose control over what data is collected and how it is collected.
- Data accuracy becomes a concern – without a clear understanding of your data collection methods, can you truly trust the data you collected?
If you are comfortable with this approach, feel free to proceed with it.
Here is a resource I found for those who prefer alternative methods. The article explores three other ways to install GA4 on your site.
I will opt for the method I know is the most RELIABLE.
If you are building your website from scratch, you will likely need the assistance of developers to insert the codes, a process that can take one to two months. However, I believe that many of you reading this post are just starting and might not want to incur this substantial additional cost.
So, let me explain why I made the choices I did. The core idea here is this:
- We have established that we must insert specific code into the HTML of our website for data collection.
- This HTML code typically resides in the Themes editor code, or if you’re using Shopify, it’s found in the Code snippet.
- The challenge arises when our website’s theme requires an update. When that happens, the code we have inserted gets erased. This presents a significant problem – it means our data collection stopped with every new update.
How do we navigate this challenge? We need a solution that allows us to insert the code and ensure it won’t be erased, even when our website’s theme gets updated. So, what is the solution?
Well, it’s something called “plugins.” Plugins allow us to preserve the code, no matter what changes our website’s theme undergoes.
4 Steps to Set Up GA4 in WordPress
My method involves using plugins to insert the necessary code into the data layer. This approach not only saves time but is also user-friendly.
These are the 2 plugins I have initially considered:
Upon reviewing the features and the types of events and data they tracked, I decided to go with the GTM Kit. The reason is that it covers essential configurations, such as page views, and even caters to e-commerce aspects.
Even though, as of the current writing, my blog doesn’t incorporate e-commerce elements, it is a part of my long-term plan. I like to approach things with a long-term perspective, and having a solution that accommodates both my immediate and future needs is essential to me.
The best part is that it comes at no extra cost. That being said, both plugins work fine, but for this guide, I will walk you through the 4 steps using the GTM Kit, the one I picked for my blog.
Step 1: Create a Google Analytics Account
Begin by setting up your Google Analytics account and property. Obtain your GA4 Measurement ID, which can be found in Admin > Property Settings > Data Collection and Modification > Data Streams. Copy the Measurement ID, which should start with “G-XXXXXXXXXX.”
Step 2: Create a Google Tag Manager Account
Then, set up your Google Tag Manager account and grab your GTM Container ID. You can find it in multiple places, such as the top right of the interface or in the Admin section. It should start with “GTM-XXXXXXXX”.
Step 3: Install the Google Analytics plugin for WordPress
Next, download the GTM Kit plugin, but do not unzip the folder. In your WordPress dashboard, go to Plugins > Add New > Upload your zip file and click Install. Once installed, click Activate. Follow these steps to complete the installation:
Installation Steps | Instructions |
Copy and paste the GTM Container ID you obtained in step 2. Click ‘Save and Continue’. | |
Toggle on the ‘Page Type’. Click ‘Save and Continue’. | |
This step is optional, depending on your comfort level with sharing information. I opted to toggle it on. Once you are done, click ‘Save and Continue’. | |
Here, you need to download 2 files: 1) Google Analytics 4 – Basic Configurations 2) Google Analytics 4 – eCommerce Open them in new tabs, right-click, and save them as Adobe Acrobat document files. |
Step 4: Import the files into Google Tag Manager
In Google Tag Manager, navigate to Admin > Container > Import Container.
- Select the file you downloaded in WordPress
- Choose the existing workspace or default workspace
- Choose Merge > Overwrite
- Click ‘Confirm’
Repeat this process for both files.
This is what you should see in GTM after importing.
You may then go ahead to publish your tags. But, I recommend conducting Quality Assessment (QA) before doing so.
Quality Assessment Methods
Before publishing the tags, it is essential to perform a quality assessment (QA) to ensure the tags fire correctly on your website. There are multiple methods to do this:
Method 1: Via GTM Preview Mode
- In GTM, click on Preview here.
- Type in your website URL.
- Click Connect. Your website and the tag assistant should load.
The next step is to explore your website by visiting different pages. In tag assistant, you should see that tags are firing. A successful tag trigger will look like this.
Method 2: Via DevTools
- Make sure you are in the preview mode.
- Navigate to your website page, right-click anywhere on the page, and select “Inspect”. This action will open the DevTools panel.
- In the DevTools panel, go to the “Network” tab.
- Use the filter for ‘collect.’
Now, visit any page on your website. If you spot a string that begins with “collect?v=2&”, congratulations, you are on the right track.
For those who are curious, you can also check if it is triggering the right event. In the case of a blog, the key event to confirm is a page view.
Here’s how to do it: Click on the string, then select “Payload.” You should see “en: page_view“. This is what it should look like.
Method 3: Via a Plugin
For this method, you will need to download a Google Plugin. I use Dataslayer.
After installing the plugin, you will find it in your DevTools. Now, just move around your website to trigger the event. A successful trigger will look like this.
I use all three methods for triple confirmation. Once the QA is complete, you are now ready to publish and start collecting data. Click ‘Submit’ in GTM, and you are good to go.
GA4 Set Up
Next, this section is a bonus for those who want to complete their admin configurations in GA4. Here are 5 key areas I recommend focusing on:
- Domain Configuration: Head to Admin > Property Settings > Data Streams > Configure tag settings > Configure your domain. Make sure to add your blog domain. For example, mine is thelilipath.com.
- Defining Internal Traffic: In Admin > Property Settings > Data Streams > Configure tag settings > Define Internal Traffic, add your home IP address. This helps ensure your data remains accurate. To locate your home IP address, simply go to Google and type “What is my IP address.” Google will automatically generate your Public IP.
- Reporting Identity: In Admin > Property Settings > Data Display > Reporting Identity, I personally set it to Device-based to avoid collecting user data. You can choose the option that suits your preferences. This is about how Google reconciles user data across different devices and platforms.
- Acknowledging User Data Collection: In Admin > Property Settings > Data Collection, acknowledge the User Data Collection Acknowledgment. Ensure you’ve covered the necessary disclosures before confirming this step.
- Data Retention: Under Data Settings > Data Retention, adjust Data Retention to the longest available option. For the free version, this is typically 14 months. This is crucial if you want to analyse month-to-month data over an extended period.
Quality Checks on Data
The final step is to conduct a quality check after you publish your tags in GTM. This step ensures that GA4 is collecting data in GA4. Here are 2 places to look out for in GA4:
1. Real-time Reports
This should be done right after you publish your tags in GTM.
- To access real-time data, navigate to Reports > Real-time.
- Navigate through your website. For instance, visiting different pages, and using the search bar.
- Make sure the data makes sense, such as the location and events corresponding to your actions.
2. Events Report
I recommend checking this twice: once after you have collected at least 48 hours of data and again after a week of collecting data. Here is what I will look out for for a blogging website:
First check
Go to Reports > Events and check for “page_view” event to make sure that you are collecting blog page views.
Second check
Go to Reports > Pages and Screens to see which pages your readers are looking at.
Third check
Visit Reports > Traffic Acquisition to see which channels are driving traffic to your blog.
Filter for Session source/medium here and ensure that the data makes sense for you (e.g. Pinterest, Instagram, Twitter, Facebook).
This post is all about setting up Google Analytics plugin for WordPress website the RIGHT way.
If you love to see more content like this, connect & follow me on social media to stay updated with the latest information.
Other posts you may like:
- 4 Quick & Easy Steps to Verify Google Search Console for WordPress Website
- 5 Best Google Analytics Report to Look at for Bloggers
- 5 Simple Steps to Build The Best Dashboard Your Business Needs