How to set up Google Analytics 4 for WordPress?

Published Estimated reading time: 14 minutes

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.

Google Analytics 4 - realtime overview report.

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 inject the Google Analytics tracking code into each website’s <head>…</head> section. It is JavaScript code that also includes tracking ID. 

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:

  • CMSs
  • HTML websites
  • Other websites
  • Applications

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 [1], then click Add New [2].

Add new plugin in WordPress plugins dashboard

Check if Thomas Geiger is the plugin’s author to ensure the choice. In the search window, type GTM4WP [3]. In the plugin gallery window, find GTM4WP [4] in the plugins gallery, and next click Install Now [5].

Find and install GTM4WP plugin

Click Activate [6]

Activate GTM4WP WordPress plugin.

After clicking Activate, the plugin window will open. Click plugin Settings [7]. After clicking the plugin settings window will open (see it in the second following picture).

Open GTM4WP plugin settings

Next, jump to the Google Tag Manager account and copy-paste the Google Tag Manager ID [8].

Copy Google Tag Manager container ID

Then copy-paste the Google Tag Manager ID to the GTM4WP plugin settings. In the next step, click Save Changes.

Copy-paste GTM container ID to GTM4WP plugin settings

Next, set Container Code OF/OFF radio-check to On and again click Save Changes.

Activate (on) container in WordPress GTM4WP plugin

Switch to the browser tab where you have the Google Analytics dashboard, and click Admin [13] in the left-down corner.

Entering the Google Analytics 4 Admin

In the analytics account Admin, click Data Streams [14].

Get into Google Analytics data streams

Next, click an arrow on the data stream bar [15].

Data Streams settings

The sliding screen will appear, and click on the icon [16] to copy the Google Analytics tracking ID (Measurement ID) to the clipboard.

Change the browser tab to Google Tag manager and click Tags [17].

Google Tag Manager workspace, click  "Tags"

Click New [18] to add a new tag in Google Tag Manager.

Click on "New" to add a new tag in Google Tag Manager

In the Tag screen, click Choose the tag type to begin set-up… [19], and next on a sliding layer, click Google Analytics: GA4 Configuration [20].

Paste the previously copied Measurement ID to the relevant window [21], and next click on the add trigger icon [22]

When the triggers appear, click on All Pages [23]. We want our Google Analytics code to be fired on all pages within the website.

Give the unique name to your tag [24] and next click Save [25]. 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 [26]. 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.

Connect website to test in Tag Assistant

It will open the website in another tab, and you can start testing. Tag Assistant layer window will appear. It confirms that testing works.

GTM test in Tag Assistant, on page confirmation.

Open Google Analytics debug mode. You can find it in Admin > Property > Debug Mode.

Google Analytics 4, enter the Debug View in Admin.

And now, you can see and test all the events and event parameters firing on your website.

Google Analytics 4 Debug View, visible events stream.

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.

Which is the best Google Analytics plugin for 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.

How do I add Google Analytics to WordPress without plugins?

We described this in the section above, “Installing code manually with Google Tag gtag.js.

Does Google Analytics have a WordPress plugin?

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.

How do I know if my WordPress site has Google Analytics?

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.

How do I see analytics on WordPress?

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.

Can you run analytics on any website?

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.

How do I monitor my WordPress site?

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?

How do I see traffic on my WordPress site?

In Google Analytics 4 dashboard, go to Reports > Acquisition > User or Traffic Acquisition. You can see the traffic and sources in this report section.

Is Google Analytics free to use?

Yes, it is free. Google offers a paid version with extended functionalities for more advanced usage and big websites.

Why is my Analytics not working?

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.

Do I need to install Google Analytics?

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.

Related Articles

how to disable comments in WordPress

How to disable comments in WordPress?

Published Estimated reading time: 3 minutes

Good and bad reasons to disable comments in WordPress WordPress comment systems can be advantageous, allowing users to leave reviews on your posts, which is crucial for enhancing audience engagement. However, it’s important to note that comments are not a…

Image of a schedule of WordPress accessibility day 2023

WordPress Accessibility Day 2023 

Published Estimated reading time: 3 minutes

A Global Event for Inclusive Web Experiences WordPress Accessibility Day is a global event that brings together developers, designers, content creators and users worldwide to promote and learn about website accessibility best practices. This 24-hour event, initially started in 2020…