Portada » Guide | How to install Google Analytics 4 in WordPress
Guide | How to install Google Analytics 4 in WordPress
Alejandro Frades
Is my website or my client’s website working? How do I know what I need to improve? Based on what data? I’m sure you ask yourself these questions on a regular basis. Today we explain how to install Google Analytics 4 on your website created with WordPress so that you have a tool to help you answer them.
It is important to note that after Google’s announcement that Universal Analytics properties will disappear in 2023, we will focus on the new version of Google Analytics 4 and how to configure it for your WordPress website.
Tabla de contenidos
What is Google Analytics?
Google Analytics is the tool par excellence for monitoring and analysis of websites, and with it you can analyse all the data of your page. Yes, as we told you.
Can you imagine knowing the characteristics and behaviour of your audience? How much would you give to know where your web traffic comes from? We know a lot, that’s why we are here today, talking about the tool that will allow you to discover all these insights and keep control over everything that happens on your website or online shop.
We don’t want to make it difficult for you, our goal is that you understand it and put it into practice. So first of all, keep in mind that Google Analytics doesn’t work by accident. We have to connect it to the website we want to analyse.
So, stick with us and let’s get started. If you are here because you want to know how to work together with WordPress and the famous analytics tool, we won’t make you wait any longer, let’s get started!
Benefits of installing Google Analytics in WordPress
Well, you can already guess that there are going to be many, right? We don’t want to take away your reason, because what you’re thinking is as real as life itself
Data acquisition and statistics: We have already discussed it a little while ago, but Google Analytics will allow you to know multiple data of the users who access your WordPress site. For example, you will know the number of visitors, the new users who access, the origin of the visits, the interaction time, as well as the conversions.
Do you have spectacular KPIs but lack information to calculate them thoroughly? Well, Google Analytics will make it easier for you to track them with exact data.
You can optimize your website by modifying those strategies that do not work. That a page has a high bounce rate? We analyze why it is happening. What is your website not converting well? We see what data Google Analytics offers us and make decisions. You can also use web performance tools to perform a more in-depth analysis.
It’s free. They have no cost, so you will lose absolutely nothing to try it.
Connect Google Analytics 4 to WordPress / Step by Step
Keep in mind that Google Analytics requires to be connected to your website, so that in this way you are able to obtain all the data of what happens in it.
Let’s see how you can achieve it very easily.
How to sign up for Google Analytics 4
This is very simple. First you will have to access the website of the Google Analytics application itself and click on the create account button.
You can access it from your personal or business gmail account if you already have it. However, if you do not have it, follow the steps it indicates, it is very simple.
Once you enter your email, a screen like this will appear. Here you will incorporate the name you want your account to bear.
Once you click next you will need to create a property. It is important that here you establish the name that identifies your company or business. Within your account you can have multiple properties, so each property will have different data.
If you do not want to go crazy, remember to add the time slot in which you usually work, as well as the country and the main currency (very important if you are going to have ecommerce).
But beware, keep in mind that we are creating the Google Analytics 4 account. This is created by default and not the Universal. You’ll need to go to “Show advanced options” if you want to also create a Google Analytics Universal account.
We in this example are going to continue with Google Analytics 4, but implementing all this data with Google Analytics Universal is very similar.
As a last step you can select the sector in which you work, the size of your company and the objective for which you have encouraged yourself to use it.
Get the tracking code for your website
The time has come to incorporate GA into our website. That’s why you’re here.
Once you have given it to create property in the previous step you will skip a page with information of the data flow.
There we can see the flow information as the tracking ID.
In this step, and a little further down, we can find the tagging instructions, with the global website tag (gtag.js) and instructions to use Google Tag Manager if you prefer.
Install Google Analytics 4 on WP via script
As we have seen in the previous step, Google Analytics provides you with a script or code snippet (gtag.js) that you will have to copy and paste, as indicated by the configuration wizard, at the top of the <head> html code section of your website.
If you have left the previous step, you will only have to go to the GA administration panel and in the property you want to measure, look for the “Data Flow” option, there you will see the code to add in the Script.
With a copy and paste of the previous code in the Header of your website you will be ready to launch hits and offer data to your GA property.
If you need help, you usually ask your web developer so they can add it directly to the code.
Install Google Analytics 4 on WP via Tag Manager
This process is a bit more complex, since it requires you to first make an account in Google Tag Manager.
Abrir una cuenta en Google Tag Manager
In this case you will only have to go to Google Tag Manager and click on “Create account”.
It is a process similar to the one we carry out to register in Google Analytics. Now you just have to enter the name of the account (for example, the name of your company or business), choose the country where you operate and enter the URL of your website.
Enable variables in Google Tag Manager
For this tool to send all the necessary information to Google Analytics, we will have to activate the following variables:
In the variables window, the configure button will give us everything we need in this step.
Select the following variables and continue with the next step:
Create the tag that will connect us with Google Analytics 4
The next step is to create the label with the name GA 4.
Let’s go to the Google Tag Manager menu and in tags we create a new one.
There you will have to incorporate the ID that Google Analytics gave you when creating the account. However, if you already had it created, you just have to go to settings and get your identifier.
The label can bear the name you want, but it is important that you know how to identify them. In the configuration of the label we will mark the type, which in this case we refer to Google Analytics 4.
Both in the type of tracking and in the activator we are going to focus on the pages viewed, while in the ID we will enter the identifier that Google Analytics provides us (you can acquire it in the configuration of your GA account, entering tracking information), as we mentioned previously.
This is essential, since if we do not carry it out, we will never be able to connect both tools and therefore, the user’s behavior on the website will not be reflected in the analytics platform.
And beware, do not forget to publish the Google Tag Manager container. This is like making a video with drones for instagram, preparing a super cool copy and then not hitting the send button.
Install Google Analytics 4 to WP via plugin
Notice that you were looking for how to connect Google Analytics to WordPress and in the absence of a method you get 3. That’s the good thing about these tools, they’re flexible at best.
Add Google Analytics plugin
If you do not have technical knowledge or anyone who can help you by putting the code, do not worry, because you can use one of the many plugins that exist for this task.
Here we recommend one that although it is not the official one, if it is one of the most used. It’s called “Google Analytics Dashboard for WordPress.”
However, there are others such as “Google Analytics by Yoast”, “Better Google Analytics”, “Simple Universal Google Analytics” or “MonsterInsights”.
Once installed and activated, we can configure it by adding our Google Analytics property ID and also, within WordPress itself, it will give us personalized statistics reports.
The other option in plugin form would be “Insert Headers and Footers by WPBeginner”.
This allows you to incorporate all kinds of scripts to your WordPress website in a very simple way, so you can start working with Google Analytics without having coding knowledge. As with other tools.
Check if we have taken the right steps
How to confirm that it is working is the simplest part of this whole process.
Simply open the web page you’re analyzing in parallel with the Google Analytics real-time report.
The moment an active user appears (it’s you, obviously) you can stay at ease, because you have achieved it.
We recommend, for testing, that you open the web on a mobile phone and in an incognito window on your computer and try to browse the site. In the real-time Analytics tab you should see what pages you have open (although beware, it takes a few seconds to update).
Once you have finished this configuration you can start seeing reports of users, origin, devices they use, pages that are most successful and a long etc of metrics offered by the tool.
But the implementation process does not end here, even if the data is received, so we continue to move forward.
Cookie banner for GDPR
It is very important that you know that, in case your users are in the European Union, you must obligatorily ask for their consent to be able to add the mediation cookies installed by GA.
Therefore, it is very important that when customizing the cookie banner you indicate that the user must accept their use before they are loaded in the browser.
And how do we do this?
Luckily we have different WordPress plugins that allow you to choose which cookies are loaded before accepting the cookie banner and which are loaded later. Just like the style and configuration of the banner itself.
The two plugins with which we have worked and that are the most used in the WP world are:
Complianz | GDPR/CCPA Cookie Consent: this plugin allows you to comply with the GDPR optimally and also has a wizard that makes its configuration much easier.
CookieYes | GDPR Cookie Consent & Compliance Notice: This is one of the best plugins for GDRP compliance since it is also compatible with other international cookie laws.
Add filters in Google Analytics UNIVERSAL
We are going to make a stop in the configuration of Google Analytics 4, since at the moment only filters are shown for the properties of GA Universal. If the default data offered by Google Analytics is already impressive, the incorporation of filters will make you obtain even more accurate data and aligned with what you are looking for.
In this section we are going to talk about how to put these filters and which are the most common to obtain more accurate results.
If we go to the configuration tool within our Google Analytics property and click on all the filters, we will find the possibility of adding a new one.
However, as we have said before, there are many options and now we are going to see some of the most important:
1. Include or exclude all traffic from certain IPs. To give an example, can you imagine that your employees entered the website a total of 50 times in the same day? You who have no record of this fact, think that they are new interested users, when they are really your own workers. You can avoid this, excluding traffic that comes from their IPs.
2. Include or exclude traffic to subdirectories
In the event that you are not interested in capturing traffic from some of the pages of your website, this filter is ideal, since you can choose that subdirectory that you do not want to deliver data to Google Analytics.
3.Analyze users from certain geographical areas
In case you want to analyze only the traffic coming from a certain country, you will choose the custom filter including the country field and setting in the field its name, in our example “Spain”.
Set up goals based on Analytics events
There is a fundamental aspect in Google Analytics, and it is the possibility of incorporating events that refer to actions that the user performs on the website, all with the aim of being able to measure them. If you also want to put them as the basis of your goals, you also have the option.
Create events with Google Tag Manager
Keep in mind that if you do not have coding knowledge, Google Tag Manager is the best option to create these events.
You should know that there are events of all kinds, so let’s see the example of “Page view”. We will create it and then set it in Google Analytics as a goal.
Page View
First, you need to create a tag that references either Google Analytics Universal or Google Analytics 4, as this is where the actions will be measured.
In this case, we will create a new tag within the “Tags” section.
It is important to note that the tracking type is “Event,” where you will provide a category, an action, a label, and a value (if applicable).
These data points are crucial as they allow us to identify the action the user is taking, thereby providing context and avoiding any confusion.
In second place, it is important to establish a trigger, so that event will only be activated when the requirement you are about to mark is met. In this case, page view.
The final result would be as follows, so all that would be left is to save and analyze the preview. If we see that it works, we can go ahead and send it and start receiving the information.
How can you mark this event as a goal within Google Analytics 4? It’s very simple.
In Google Analytics Universal, we would have to go to Settings and then Goals. In the case of GA 4, there have been several modifications. We will have to go to “Configure” where we will click on Conversions. Now, we are ready to create the goal. How? By creating a new conversion event. In other words, we are going to mark the event we previously generated in Google Tag Manager as a conversion.
Once we have it created, it will only be necessary to mark it as a conversion. This way, we will have our goal created.
Then, we would only need to save and wait for the initial data, which will most likely start being counted from the following day.
Start saving time and earning more money with your maintenance contracts.
Start managing all your WordPress websites from one place.
As we can see, Google Analytics has great potential, especially when it comes to integrating it with your WordPress site. This way, you can stay informed about everything that happens on your website.
And as Google has indicated, the future lies in Analytics 4, so it’s time to start using it. However, we advise against upgrading to GA 4 using the button that appears in Universal Analytics.
It is advisable to install GA 4 now and keep the Universal Analytics script if you already have it. This way, we can continue working with Universal while we learn to handle the new version. In 2023, when Analytics 4 becomes the only option, we will have the data history from the past year (there is no migration of historical data between the two).
Autor
Alejandro Frades
Marketing Specialist
The mind behind Modular's social content. Always on top of the latest trends to take advantage of them and make the digital world more enjoyable and entertaining.
Utilizamos cookies propias y de terceros para fines analíticos como la medición de la actividad de la web e introducir mejoras para el usuario. Puede consultar más información a continuación.
Funcional
Always active
El almacenamiento o acceso técnico es estrictamente necesario para el propósito legítimo de permitir el uso de un servicio específico explícitamente solicitado por el abonado o usuario, o con el único propósito de llevar a cabo la transmisión de una comunicación a través de una red de comunicaciones electrónicas.
Preferencias
El almacenamiento o acceso técnico es necesario para la finalidad legítima de almacenar preferencias no solicitadas por el abonado o usuario.
Estadísticas
El almacenamiento o acceso técnico que es utilizado exclusivamente con fines estadísticos.El almacenamiento o acceso técnico que es utilizado exclusivamente con fines estadísticos anónimos. Sin una requerimiento, el cumplimiento voluntario por parte de su proveedor de servicios de Internet, o los registros adicionales de un tercero, la información almacenada o recuperada sólo para este propósito no se puede utilizar para identificarlo.
Marketing
El almacenamiento o acceso técnico es necesario para crear perfiles de usuario para enviar publicidad, o para rastrear al usuario en un sitio web o en varios sitios web con fines de marketing similares.