Table of contents
  1. What is Google Analytics?
  2. What are the benefits of linking WordPress and Google Analytics?
  3. Who should consider incorporating Google Analytics into WordPress?
  4. What should I consider when linking WordPress and Google Analytics?
  5. Ways to Install Google Analytics GDPR-Compliant in WordPress
  6. Use Borlabs Cookie for setting up Google Analytics in WordPress
  7. Integrate Google Analytics with Borlabs and Google Tag Manager in Wordpress
  8. Checklist for Integration of Google Analytics into WordPress
  9. Conclusion on Integration of Google Analytics into Your WordPress Website

WordPress is the most frequently used Content Management System worldwide. Nearly 43 percent of all websites rely on WordPress , followed by Shopify with a share of just around 4 percent. Even Website Builders, such as Wix can't keep up and are only used on about 2 percent of the websites surveyed.

Among the various Web Analytics Tools, which are now on the market, Google Analytics holds a similarly dominant position. Google itself does not publish figures on the number of websites that use Google Analytics, according to an analysis by W3Techs.com, the global market share is around 86 percent. Google also holds pole position in the field of web analytics with Google Analytics.

In his article, Niklas Buschner explains from his experience as managing director of the Digital agency Radyant, what Google Analytics is and what advantages the linking of WordPress and Google Analytics has. You will also learn when it makes sense to set up the link and how to step-by-step GDPR-compliant implement Google Analytics in your WordPress website.

Recommended web analytics software

On our comparison platform OMR Reviews you can find more recommended web analytics software. We present over 60 solutions that are specifically tailored to the needs of web analytics professionals, companies and online marketing specialists. This web analytics software offers comprehensive support in all aspects of data analysis and website optimization. Take this opportunity to compare the different software solutions, drawing on authentic and verified user reviews:

What is Google Analytics?

Google Analytics is a comprehensive Web Analysis Tool from Google, which allows you to collect data on the use of your web services. For many online marketing managers, Google Analytics is the digital Swiss army knife, as it holds data and thus answers to many different questions.

In order to be able to use Google Analytics, you first have to create an account. We tell you how to do this in our contribution on the topic: “Google Analytics with this step-by-step plan.”

If you already have an account with Google Analytics, all you need to do is to integrate the Google Analytics tracking code into your website and you can evaluate extensive data on your website visitors.

If it was that easy, however, this article probably wouldn't exist. But don't worry, with the right instructions, setting up Google Analytics tracking in WordPress is feasible for everyone.

Tip: There are many other web analytics tools that are extensively presented and rated on the Software review platform OMR Reviews.

What are the benefits of linking WordPress and Google Analytics?

You can, for example, use Google Analytics to record how many users have called up your website during a certain period. You also receive information about how your users got to your website. Did they click on one of your Facebook ads, did they search Google for a specific term and found you through a clean SEO Strategy for your WordPress website or did they come to you via a link on another website.

In addition to websites, Google Analytics can also be integrated into apps, so you can gain comprehensive insights into your digital offerings. Companies that operate websites and apps, for example, would like to find out which contents users consume both on the web and in their apps.

In order to analyze these cross-device Customer Journeys optimally, Google has decided to phase out the previous standard of Google Analytics, Universal Analytics, and Google Analytics 4 from July 1, 2023 will be the new standard. Google Analytics 4 is particularly interesting for such applications and offers a better foundation for analysis with a consistent data model.

Tip:  Founder and managing director Bjoern Sjut explains in his guest article the most important Differences between Universal Analytics and Google Analytics 4.

Who should consider incorporating Google Analytics into WordPress?

Basically, it is always useful to incorporate Google Analytics into WordPress and collect data about your digital offerings. This gives you the opportunity to better understand how your offers are used and can identify errors or potential for optimization more quickly. This is especially true for people and companies who actively use their WordPress website in online marketing.

These include the use as a Landing Page for advertisements, the Lead Generation as a B2B company or the use as a Online Store with WooCommerce. In these cases in particular, it is crucial for you to understand exactly how your users interact with the website, which channel they came to the website from, where they may leave the website again or what target projects (conversions) they carry out.

What should I consider when linking WordPress and Google Analytics?

You have already built a website or even an online shop and rely on WordPress? Google Analytics could provide you with critical insights to measure your website's performance and draw intelligent conclusions for your online marketing. If you are now thinking about incorporating Google Analytics into WordPress, there are some legal and technical details to consider.

After the General Data Protection Regulation (GDPR) came into force on 25 May 2018, there was initially uncertainty as to whether a notice or consent was required for the GDPR-compliant use of Google Analytics (and other analysis tools).

After judgments by the European Court of Justice (ECJ) and the Federal Court of Justice (FCJ) in the years 2019 and 2020, however, it is clear: Tracking tools that set cookies may only be used with the express consent of users. A simple cookie notice is therefore definitely no longer sufficient to use Google Analytics tracking.

These legal requirements also have an impact on the technical implementation of Google Analytics in WordPress. While before the GDPR came into force, you could simply write the script from Google Analytics into the header.php, this solution is no longer possible under current law.

You now need active consent, a so-called opt-in, to trigger the Google Analytics tracking code. However, this does not mean that you can no longer use Google Analytics, you just need to include a solution for capturing and managing the consents of your users – a so-called Consent Management Tool.

Ways to Install Google Analytics GDPR-Compliant in WordPress

There are several ways to install Google Analytics in WordPress. This is mainly due to the fact there are countless Tag Managers, tracking plugins, and consent management tools. To give you as concrete assistance as possible, I will limit myself to two paths, which I have also implemented for various customers and which work cleanly.

Important notes on GDPR compliance:

  • The GDPR compliance of the implementation does not only depend on your use of a consent management tool.
  • If you use Universal Analytics, you always have to activate IP anonymization, in Google Analytics 4 this is already activated automatically.
  • In addition, you have to accept the Addenda to Data Processing.
  • Finally, you have to keep your privacy policy up-to-date and legal secure. Here, providers like eRecht24 can help you, they provide free templates for privacy policies.

Borlabs Cookie is a WordPress plugin developed in Germany, which you can use for the GDPR-compliant integration of various tracking codes. It is probably the most comprehensive and user-friendly plugin for consent management and was explicitly developed for WordPress. To put it in the words of a user who rated Borlabs on the Software Review Platform OMR Reviews: “If you use Wordpress, you can't ignore Borlabs!”

Bild 1.1 - Google Analytics in WP einbinden.png.png

Requirement for using Borlabs Cookie

The plugin is not free, so you first have to acquire a license. The price is very reasonable considering the large range of functions. In addition, the fines that threaten in case of data protection violations are so high that the investment in a good consent management solution is definitely worthwhile.

Step 1: Installation of Borlabs Cookie

In order to be able to integrate Google Analytics into WordPress via Borlabs Cookie, the installation and activation of the plugin is required. For this purpose, you will find two good and compact instructions directly at Borlabs. First, you have to install Borlabs Cookie and activate your license and then set up the Cookie Box. This is displayed to users of your website when they call it up and asks whether cookies may be set or not.

Step 2: Integration of the Google Analytics Tracking Code

To now set up your Google Analytics tracking code, navigate to the “Cookies” tab in Borlabs and click the “Add New” button in the “Statistics” group.

Bild 2 - Google Analytics in WP einbinden.png.png

You then have to select a service. Borlabs has already listed some well-known tracking tools here. In addition to Google Analytics, you can also find the Google Tag Manager, Hotjar or Matomo (zuvor Piwik). You now select Google Analytics.

Bild 3 - Google Analytics in WP einbinden.png.png

Borlabs Cookie has already added some standard information for you. This includes in particular the name of the provider, the purpose of the cookies, a link to the provider's privacy policy and the tracking code.

Now, under “Additional Settings”, all you have to do is enter your tracking ID. This should initially be your property ID from Universal Analytics.

Bild 4 - Google Analytics in WP einbinden.png.png

You can find this in the settings of Google Analytics under “Property Settings”. You can tell that you are in a Universal Analytics property by the fact that “UA-...” is behind the name of the property.

Bild 5 - Google Analytics in WP einbinden.png.png

Step 3: Use Universal Analytics and Google Analytics 4 in Parallel

If you want to use Universal Analytics and Google Analytics 4 in parallel, you have to adjust the ID. You can firstly set up Google Analytics 4 and leave the ID of the cookie on google-analytics and then just create another cookie with the Google Analytics service and then adjust the ID for Universal Analytics to universal-analytics.

Step 4: Update Cookie Version and Put New Configuration Live

As a final step, you navigate to the “Settings” tab. Click on “On” in the dropdown menu next to “Update Cookie Version & Enforce Relisting” and then on “Save All Settings”. So your cookies are live.

Bild 6 + 15 - Google Analytics in WP einbinden.png.png

Step 5: Check Correct Integration of Google Analytics with Borlabs Cookie

You can check the error-free integration by opening your website in an incognito window. Depending on the browser and operating system, this is done via the system bar of the program. Agree to all cookies in the incognito window and open the real-time report in Google Analytics in parallel. You should now be able to track your activities live on the website.

Bild 7 - Google Analytics in WP einbinden.png.png

Real-Time View in Universal Analytics After Correct Implementation of Google Analytics in WordPress

Bild 8 - Google Analytics in WP einbinden.png.png

Real-Time View in Google Analytics 4 After Correct Implementation of Google Analytics in WordPress

Integrate Google Analytics with Borlabs and Google Tag Manager in Wordpress

If you already use Google Tag Manager, you can also integrate Google Analytics through it in connection with Borlabs Cookie. In this way, you benefit from the flexibility of the Google Tag Manager, combined with the user-friendly consent management solution from Borlabs Cookie.

Step 1: Integrating Google Tag Manager in Borlabs Cookie

First, you have to integrate the Google Tag Manager into your WordPress site, as it contains all your tracking codes and thus also Google Analytics. In Borlabs Cookie you navigate to the “Cookies” tab and click there on the blue “Add New” button within the Cookie group “Essential”.

Bild 9 - Google Analytics in WP einbinden.png.png

You then choose Google Tag Manager from the suggested services. Do not choose “Google Tag Manager - Consent” here. Whether the Google Tag Manager is classified as essential or technically necessary is currently legally disputed. However, we assume that, as it does not trigger its own tracking but is merely the technical container for other tracking codes.

Then enter your GTM ID and turn the switch next to “Cookie before Consent” to “On”. Click on “Save All Settings” and the Google Tag Manager is listed as a service in Borlabs Cookie.

Bild 11 - Google Analytics in WP einbinden.png.png

You can find your container ID directly in the overview when you visit https://tagmanager.google.com/.

Bild 12 - Google Analytics in WP einbinden.png.png

Step 2: Incorporate Google Analytics

Now we need to create a cookie for Google Analytics in Borlabs Cookie. We need this to send the status of the consent from your visitors to the Google Tag Manager.

For this, you navigate to the “Cookies” tab in Borlabs and click the “Add New” button in the “Statistics” group.

Bild 2 - Google Analytics in WP einbinden.png.png

You then select Google Analytics.

Bild 3 - Google Analytics in WP einbinden.png.png

Unlike the direct integration of the Google Analytics tracking code, we do not have to enter a Tracking ID now. You just write “none” or “000” in the field. Delete the code in the “Opt-in Code” field and insert the following code there. This sends an event to the Google Tag Manager when the consent of the visitors was given.

<script>
⁠window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
⁠    event: 'borlabsCookieOptInGoogleAnalytics',
  ⁠});
⁠</script>

Bild 14 - Google Analytics in WP einbinden.png.png

The name of the event is freely chosen and can also be different. It is only important that it is unique and not used by other scripts.

Step 3: Update Cookie Version and Put New Configuration Live

In order to activate the two new cookies in Borlabs Cookie, you navigate to the “Settings” tab. Click on “On” in the dropdown menu next to “Update Cookie Version & Enforce Re-selection” and then on “Save All Settings”. So you have your cookies live and you can check the configuration after the following setup steps in the Google Tag Manager.

Bild 6 + 15 - Google Analytics in WP einbinden.png.png

Step 4: Create Tag and Trigger in Google Tag Manager

Now all you need to do is create a tag and the right trigger for Google Analytics in Google Tag Manager. Click on “New” in the “Tags” tab.

Bild 16 - Google Analytics in WP einbinden.png.png

Then an overlay opens. There you click right in the middle of the tag configuration area. Select the appropriate tag for you, either Universal Analytics or GA4 Configuration.

Bild 17 - Google Analytics in WP einbinden.png.png

If you want to install Universal Analytics, you have to create a variable for the Google Analytics settings. For this, click on “New Variable” under “Google Analytics Settings”.

Bild 18 - Google Analytics in WP einbinden.png.png

Enter the UA-... starting tracking ID under Tracking ID and under the fields to be specified, you add a field with the name “anonymizeIp” and the value “true”. The configuration should then look like in the following screenshot. Name the variable, for example, “Universal Analytics” and save it.

Bild 19 - Google Analytics in WP einbinden.png.png

If you create a tag for Google Analytics 4, you can enter the Measurement ID directly in the tag configuration. No further settings are required there.

Bild 20 - Google Analytics in WP einbinden.png.png

In order for the tag to be able to be executed, we still need a trigger. For this, click simply in the middle of the area “Trigger” again and in the opening overlay right above on the plus.

Bild 21 - Google Analytics in WP einbinden.png.png

In the new overlay, click right again in the middle area and select the trigger type “Custom Event”.

Bild 22 - Google Analytics in WP einbinden.png.png

In the “Event Name” input field, you enter the name of the event used in Borlabs Cookie: borlabsCookieOptInGoogleAnalytics. Finally, give your tag a speaking name and save it.

Bild 23 - Google Analytics in WP einbinden.png.png

[Optional] Trigger Events in Google Tag Manager

After you have now set up the consent with Borlabs Cookie and triggering Google Analytics with the Google Tag Manager, you could create additional events. Usually, these are clicks on certain buttons or the calling up of a thank you page after a form. In order to ensure that these events are only triggered when the consent in Borlabs Cookie was granted, you have to set up a corresponding Consent variable in the Google Tag Manager.

Borlabs Cookie provides a further instruction for this, which shows you step-by-step how to create such a variable and trigger events only when the consent for Google Analytics was given.

Bild 24 - Google Analytics in WP einbinden.png.png

Step 5: Check Correct Integration of Google Analytics with Borlabs Cookie and the Google Tag Manager

It is important that you check your setup to make sure the tags are triggered correctly. First, click on “Preview” at the top right in the Google Tag Manager.

Bild 25 - Google Analytics in WP einbinden.png.png

An input field then opens in which you enter your URL. Click on “Connect” afterwards.

Bild 26 - Google Analytics in WP einbinden.png.png

You then have a Google Tag Assistant tab open and a tab in which your just entered URL is displayed. In the tab of your URL, you must once accept the cookies. You should then be able to see in the Google Tag Assistant tab that both the event and the respective tag have been triggered.

Bild 27 - Google Analytics in WP einbinden.png.png

If everything looks like in the screenshot, you have successfully implemented Google Analytics with Borlabs Cookie and Google Tag Manager.

Checklist for Integration of Google Analytics into WordPress

If you are currently thinking about implementing Google Analytics into WordPress, there is a lot to consider. To make the process as easy as possible for you, we have developed this short checklist for you.

  1. Do you already have a property for Google Analytics 4? If not, you should definitely do that, as Universal Analytics will stop processing data from July 1, 2023. An early implementation of the new version of Google Analytics is therefore important.
  2. Do you already have a consent management solution in use? If not, take a look at Borlabs Cookie. This is a tool that was explicitly developed for WordPress and makes the obtaining of consents for the GDPR-compliant use of tracking tools much easier.
  3. Are you using the Google Tag Manager and want to integrate Google Analytics through it? No problem, this is also possible with Borlabs Cookie and the instructions in this article.
  4. Have you already updated your privacy policy and indicate there the use of Google Analytics? If not, then check out the Privacy Policy Generator of eRecht24, with which you can create a privacy policy provided by lawyers in a few clicks.

Conclusion on Integration of Google Analytics into Your WordPress Website

In this article, I gave you a comprehensive insight into the integration of Google Analytics into WordPress. You now know what the current legal situation is and what a GDPR-compliant implementation looks like. Please note that I can not give legal advice and the information was prepared to the best of my knowledge, but is always without guarantee.

You also got to know a consent management tool for WordPress, with which you can implement Google Analytics in just five steps. It doesn't matter if you want to integrate your tracking ID directly or want to use the Google Tag Manager. You should now be well equipped to better judge the performance of your website and I am curious to see what analyzes you will do.

Niklas Buschner
Author
Niklas Buschner

Niklas Buschner ist Geschäftsführer der Radyant Digital GmbH. Seit 2013 arbeitet er im Online-Marketing und brennt für Google Ads und SEO. Mit seinem Team unterstützt er Kund*innen dabei, systematisch mehr Umsatz über Google zu generieren und nachhaltig zu wachsen.

All Articles of Niklas Buschner

Software mentioned in the article

Product categories mentioned in the article

Related articles

Join the OMR Reviews community to not miss any news and specials around the software seeking landscape.