Marketing campaigns should be evaluated using data. When using your WordPress website visitors’ data, you can tailor your marketing efforts for your target audience to convert visitors into leads.
Tracking WordPress site visitors and their behaviour can help you run a successful online business and improve your paid and organic campaigns.
This article explains how to, in the most effective way, connect Google Analytics 4 to your website. We are recommending one method, using Google Tag Manager as the most effective and flexible setup.
It is suitable for adding Google analytics fundamental installation. It is also ready for changes and amendments to create precise website data tracking.
- How do I implement analytics in WordPress?
- How to add analytics using dedicated WordPress plugins?
- Installing code manually with Google Tag gtag.js
- Installing using Google Tag Manager
- What is needed to start the installation?
- Step-by-step tutorial on how to install Google Analytics in WordPress.
- Test the whole setup using Tag Assistant & Debug View.
- Summary for the Google Analytics 4 implementation.
- FAQ – Google Analytics & WordPress.
How do I implement analytics in WordPress?
There are several ways of installing analytics on the WordPress site. The most popular are:
- Using functional (special) plugins
- Inserting code manually (inserting Google Analytics tracking code gtag.js)
- Installing using Google Tag Manager, WordPress plugin (GTM4WP) and Google Analytics 4
How to add analytics using dedicated WordPress plugins?
Currently, on the WordPress.org repository, you can find several dozen plugins dedicated to deploying Google Analytics in WordPress. The most popular are Site Kit by Google, MonsterInsights, Analytify, WP Statistics and many more.
You need to have a Google Analytics account before you begin setup. In most cases, setup demands only copy-paste a measurement ID to the plugin’s settings. You can find measurement ID in the data stream settings.
These plugging offer extended features and access to analytics inside the WordPress dashboard. For obvious reasons – CMS limitations- these features differ from those in the Google Analytics panel.
Also, to have analytics reports and graphs in the WordPress dashboard, plugins need to write data to the database, which leads to increasing database size and can impact the website’s performance.
Installing analytics using the plugins mentioned above may work for inexperienced users, but there are better solutions for many reasons.
The most important are:
- These plugins are heavy.
- They are causing database bloat.
- They significantly decrease website security.
- Google Analytics reports offered by these plugins are limited and useless for any serious analysis.
- When using these plugins, you are limited to their features. So you can’t use all the features offered by the new Google Analytics 4 (e.g. can’t modify events, add custom events or event parameters etc.)
- The free version of the plugin can have minimal functionalities (Monsterinsights plugin)
- When you decide to change to a different solution, these plugins will likely leave data in the database.
We advise that if you have basic WordPress and Google Analytics skills, don’t install Google Analytics 4 using this solution. We will later in this article show an excellent way to start collecting and analysing data without further limitations.
Installing code manually with Google Tag gtag.js
You can find this code in Google Analytics 4 in the Admin section. Go to Admin, next click Data Streams, next click View Tag Instructions (on the very bottom of the window) and in the next window. Click Install manually. The additional window will open, and you can copy-paste the JS tracking code.
Examples where you can deploy this code:
- HTML websites
- Other websites
The whole operation of installing Google Analytics 4 on the WordPress website using gtag.js is to inject the Google Analytics tracking code to the <head>…</head> section on the website.
You can do it using one of the plugins (not recommended) or manually inserting code into the template <head> section. The developer should do this operation, or you can do it yourself if you know how.
This way of installing analytics on your website also has limitations. When you decide to extend the scope of events or add custom, you will need editing of the gtag.js code.
Installing using Google Tag Manager
This method doesn’t require any advanced knowledge of WordPress, and there’s no need to know even the basics of coding. It has many advantages and allows you to set up advanced tracking. This installation also will need to install one plugin.
That implementation does not have future limitations and allows easy installation of EEC (enhanced e-commerce), integrated with a well-known contact form plugin (Contact Form 7) and many others. We will talk more about it later.
What is needed to start the installation?
- Admin access to the WordPress website
- Admin access to existing Google Analytics 4 account (if you don’t have it, you will need to set up a new account, here you can find the tutorial on how to do it),
- Google Tag Manager account (if you don’t know how to set up GTM, here is the tutorial on how to do it)
The process will take about 30 – 60 minutes, depending on your skills and experience.
Additional advice. A good option is to open the following app before setup:
- WordPress dashboard
- Google Analytics
- Google Tag Manager
Open the following browser tabs to allow easy navigation between app windows and copy-paste needed elements between apps.
Step-by-step tutorial on how to install Google Analytics in WordPress.
Go to the WordPress dashboard, click Plugins , then click Add New .
Check if Thomas Geiger is the plugin’s author to ensure the choice. In the search window, type GTM4WP . In the plugin gallery window, find GTM4WP  in the plugins gallery, and next click Install Now .
Click Activate 
After clicking Activate, the plugin window will open. Click plugin Settings . After clicking the plugin settings window will open (see it in the second following picture).
Next, jump to the Google Tag Manager account and copy-paste the Google Tag Manager ID .
Then copy-paste the Google Tag Manager ID to the GTM4WP plugin settings. In the next step, click Save Changes.
Next, set Container Code OF/OFF radio-check to On and again click Save Changes.
Switch to the browser tab where you have the Google Analytics dashboard, and click Admin  in the left-down corner.
In the analytics account Admin, click Data Streams .
Next, click an arrow on the data stream bar .
The sliding screen will appear, and click on the icon  to copy the Google Analytics tracking ID (Measurement ID) to the clipboard.
Change the browser tab to Google Tag manager and click Tags .
Click New  to add a new tag in Google Tag Manager.
In the Tag screen, click Choose the tag type to begin set-up… , and next on a sliding layer, click Google Analytics: GA4 Configuration .
Paste the previously copied Measurement ID to the relevant window , and next click on the add trigger icon 
When the triggers appear, click on All Pages . We want our Google Analytics code to be fired on all pages within the website.
Give the unique name to your tag  and next click Save . It is good to paste a Measurement ID to the tag name because it is easier identification of tags when you test in Tag Assistant.
Last but not least, click Submit . You must submit Google Tag Manager container changes; after this, changes are going live.
Test the whole setup using Tag Assistant & Debug View.
The good practice is to test your Google Analytics WordPress setup before going live. Before publishing, it is necessary to test the setup and ensure that the data are coming in and displaying correctly through the debug functionality.
To start testing, click Preview in Google Tag Manager, which will open a Tag Assistant window.
In the next step, enter the website address and click Connect.
It will open the website in another tab, and you can start testing. Tag Assistant layer window will appear. It confirms that testing works.
Open Google Analytics debug mode. You can find it in Admin > Property > Debug Mode.
And now, you can see and test all the events and event parameters firing on your website.
Summary for the Google Analytics 4 implementation.
Correct implementation of the code will provide valuable analytics data for your business. It is an important part of tailoring your marketing efforts for your target audience to convert visitors into leads.
Tracking and analysing your WordPress website visitors and their behaviour can help you to tweak and improve your paid and organic campaigns.
Please read the questions and answers below for more information.
FAQ – Google Analytics & WordPress.
There’s no one answer to this question. It depends on your needs, your current setup and your skills. We generally empower people to use plugins sparingly and to have the best outcome for specific circumstances. If you need advice in this area, please contact us, and we will choose the best way of implementation after auditing your website.
We described this in the section above, “Installing code manually with Google Tag gtag.js.
Yes, Google developed a WordPress plugin you can use to add Google Analytics to the website. It is a Site Kit by Google plugin. This plugin is heavy. It includes several external libraries and scripts which can impact website security. The plugin also writes tons of data to the WordPress database, causing bloating the database. Last but not least, it offers minimal analytics reports. These issues disqualify this plugin as an excellent way to integrate google analytics with the website.
There are several ways of checking your current Google Analytics setup. You can install the Google Chrome plugin “Tag Assistant Legacy” (link here). There’s a new Google Tag Assistant (check this link https://tagassistant.google.com/). With these plugins, you can quickly review and validate your Google Analytics setup and the details and performance of tags on your website.
Please check the answer to the question, “How do I know if my WordPress site has Google Analytics?”. Additionally, you can check what plugins are installed in the WordPress dashboard.
Also, check the website’s code and search for “UA-” for Universal Analytics or ‘G-” for Google Analytics 4. To see the website code, use “CMD+ALT+U” on OSX devices or “CTRL+ALT+U” on MS-based devices. Use the essential combination CMD(CTRL) + F to search and insert your search query.
Yes, you can. There are several possible ways of setting up a Google Analytics property on your website or app. If you need to dig deeper into this topic, please check your CMS or app manual for installing Google Analytics. If you have trouble with it, please don’t hesitate to contact us. We’re happy to help.
The best way to monitor your website performance (Events/Users/Monetisation and others) is to check reports in Google Analytics 4. If you want to learn more about GA4, read our article on 360DigitalCare.com – Google Analytics 4. How To Start a New Adventure?
In Google Analytics 4 dashboard, go to Reports > Acquisition > User or Traffic Acquisition. You can see the traffic and sources in this report section.
Yes, it is free. Google offers a paid version with extended functionalities for more advanced usage and big websites.
There are several reasons which can cause problems with data collection. Each case is different, and you need to investigate it using mentioned above tools. If you have trouble with it, please don’t hesitate to contact us. We’re happy to help.
No, you don’t need to install any analytics. Still, your website performance is crucial to optimising your business marketing and sales funnel if your business relies on online acquisition. So we can say yes. You need to install Google Analytics if your website is your acquisition channel.