How to install Google Analytics in WordPress –

Hosting Mautic QuickStart -50% with support in Spanish
24 hours and free training

Send up to 1,000,000 emails/year. Mautic support in Spanish 24 hours, 365 days

“If it can’t be measured, it doesn’t exist” It is a phrase that we have heard at many conferences on e-commerce and digital projects around the world.

The importance of measuring what happens on our websites goes beyond installing a simple counter like we did in the 90s. A vanity metric that simply made us happier the more the number increased 🤦🏻‍♀️.

But now everything has changed and the counters have been called data and the reports of tools such as , or the Open Sources alternatives and , are essential to show your solvency as a digital business.

Beyond the tool, what we should care about when collecting data from our visitors is establishing the business model we are creating, knowing the product funnel, establishing KPIs, looking at the metrics that matter and all this methodology of lean analytics that any startup knows and loves. Let’s get off the cloud and start implementing the first step of your new data policy on your WordPress website: install Google Analytics 🤘🏻.

What is Google Analytics

It is a tool of analytics that tracks the clicks made by a person who visits your website. It is quantitative, it offers you numerical data on the behavior of your users.

With it we will be able to know a whole series of behaviors that will surely come in handy to make decisions based on data. I bring you here a list of the main things you will be able to know with Analytics:

  • How many visitors enter your website and most importantly: from or where they access.
  • When they enter your website. You will be able to know which of those people who visit you are recurring and know how often they return. You can also set temporary filters among other things.
  • Create custom reports with the data that most interests you for your online project.
  • know your sales and relate them to the other data you are collecting. With WooCommerce the connection is direct and you will surely be able to do it easily by following .

In addition, with Google Analytics 4 you will be able to do many more things that you previously needed from Google Tag Manager to configure them finely. Some of these improvements are:

  • No more double analytics Google Analytics and Firebase. If you have an application, now you can relate it to Google Analytics and have all the unified data.
  • All behaviors are treated as events, there are no page views, no custom event set by us, no nothing. They are all events and already 😄.
  • targets disappearare now called conversions.
  • no bounce anymorebut you will have to create a specific metric to calculate it.
  • Users who interact with your site are now called “Active Users”. Very related to a very common metric that is DAU, WAU, MAU, etc. (Daily Active Users, Monthly Active Users, in English).
  • You lose your data history if you previously had Google Analytics already installed. But you can keep your Universal Analytics active to continue seeing that data.
  • Adds a series of default events that we previously had to add manually with Tag Manager. One of the most valuable is the internal search. Now we will know what our users are looking for on the web.
See also  I can't collect rss from my website for a mobile app

Sign up for Google Analytics 4

There are two requirements you need to sign up for Analytics:

  • Have a Google account, either from Gmail, Gsuite or one from your own domain but that you register with Google.
  • Have a web page or app to measure. Obvious… 😅

And now come the steps to create your account:

  1. Access and log in with your Google account.
  2. Create your Analytics account. Tell you that when you sign up for Analytics you are creating a user of this service. And within this user you can create several accounts.

Analytics User > Account > Properties > Data Flows

It is the organization hierarchy of this tool. You can have accounts for your client websites for example and then another account for your personal websites. Although for example to manage clients, the most recommended is to create an account per client. Who knows if that same client later asks you to make more websites 😉.

  1. Create your property. A property is a digital project. Being understood by digital project, for example, an online store. Then that online store can have an app and a website that will be each of the “data flows”, the next level of Analytics.
  2. Create your data flow. If it is a website made with WordPress, then choose Web Application.
  3. The app now gives you a tracking code. Here you have the data to install Analytics on your WordPress website in different ways.

Install Google Analytics with Plugin

Without a doubt, the best option is to directly install a plugin that complies with the law, therefore We recommend that you use the easiest plugin to comply with the European GDPR regulation and that is

.

Install Google Analytics with Tag Manager

This is another option that requires a previous step: create a Google Tag Manager user. To do this, we first go step by step:

  1. Sign in to https://tagmanager.google.com/ with your Google account.
  2. Create an account to which we will add a container, here the relationship is as follows:

User Tag Manager > Account > Containers.

Containers will be like “data streams” in Analytics. Here we do recommend an account per digital project 😉

  1. Give the account a name. For example “My new web page”, choose the country, and below the name of the container, for example the url of the site without the www “minuevaweb.com”, and select the type of platform that it is: in our case Website if it is a page made with WordPress.
  2. We press To createread the agreement, mark as accepted the checkbox that appears at the bottom, and press Yes up to the right.
  3. Leave this window open where the two codes to copy on your website appear, and open another tab with your website.
  4. Install and activate it.
  5. Navigate to the tab GDPR Cookie Compliance on the left side of your screen and then to Banner settings.
  6. Change to Switched on to activate the banner that will appear in your browser to accept cookies.
  7. In order for your site to comply with the regulations, you would also have to activate the option reject button and I recommend that you also activate access to the settings that should be visible to the visitor, although you can also put your link in another part of the web, for example in the footer.
  8. Save changes in the button located at the bottom.
  9. Now click on the section Third party cookies.
  10. Change the state to Switched on and default state to deactivated.
  11. Go down (scroll down) and you will see a section called Paste your codes and code snippets below. They will be added to all pages if the user allows these cookies. There you have a tab browser where you can add the tracking code in the section that the tracking provider requires. In the case of Google Tag Manager, you must copy two codes:
    • in the tab head sectionthe first code they give you where it says.
    • In the body sectionthe second starting with .
  12. Save the changes.
  13. Now go back to the Tag Manager window again and close the code information.
  14. Search tagsthen tap on New.
  15. click on Label Configuration and choose the option Google Analytics: GA4 configuration.
  16. Enter the Analytics Navigation ID. You can find that in your Analytics account created before. If you don’t have it, follow these steps:
    • Go to your Google Analytics account > All accounts top left
    • Select the account you want to manage > Admin Wheel at the bottom left > Property you want to configure > Data Flows > select your flow (your website made with WordPress).
    • Inside you have a section that puts in bold Measurement ID.
    • Copy that number that starts with G-. About the rest of the options, you can consult the .
  17. Give the tag a name for example Google Analytics or GA4 to identify version 4 of the tool.
  18. Click on the part below called Activationand select All pages so that it is installed in that… on all pages 😅.
  19. click on Save > Send to publish. Name the version as “Google Analytics 4 Installation” and click on Post.
See also  single login

Important: If you use Google Tag Manager to install Analytics, you do not need to copy and paste the Google Analytics code in the header as well, just use the Google Tag Manager code following the steps we have indicated here.

Install Google Analytics without Plugin

This option exists but I want you to know that you will not be complying with current regulations if you do it as explained by Google. Currently in Europe there is a regulation that requires that if you collect browsing data, you need to inform your visitors of them and that they accept or not the installation of cookies to measure their behavior. The famous cookie banner.

If you still want to install Google Analytics without a plugin, simply copy the code provided by the tool when you reach the end of the point Sign up for Google Analytics 4and paste that code into the tag of your WordPress theme.

How can you get it? Well, the easiest way is to add the following code by simply changing the property number (where it says G-XXXXXXXXXXXX), in the File functions.php of your theme or in a Snippets plugin like:

add_action( ‘wp_head’, ‘add_google_analytics’ ); function add_google_analytics() { ?>

Where is the functions.php file?

1️⃣ The file functions.php it’s on the desk WordPress > Appearance > Theme Editor.

2️⃣ Select the theme you have activated and click on the file called Theme Features functions.php.

3️⃣ There, paste the code at the end of everything, and hit update file. You already have it 🎉.

See also  PROBLEM when updating header IMAGE WORDPRESS template...

How do I know that Google Analytics is correctly installed?

Access the reports section in real time and with another browser or anonymous session (and after having given yes to the cookie consent). Check that your current session is being recorded. Of course, in the rest of the reports (application tabs), you will only see data after 24 hours of installation.

Most important parts of Google Analytics

🏠 Main page: It offers us a summary with the most general metrics of your website, such as the active users in the last 7 days as well as the…

Loading Facebook Comments ...
Loading Disqus Comments ...