Embed Google Analytics in WordPress [2021]

Google Analytics collects information from your visitors. This data can help you improve the user experience. In addition to visit numbers, length of stay and page views, you can also query demographic data of your visitors.

Don’t feel like reading? Then just watch our video tutorial:

YouTube

Mit dem Laden des Videos akzeptieren Sie die Datenschutzerklärung von YouTube.
Mehr erfahren

Video laden

With the introduction of the GDPR in May 2018, the guidelines for cookies were also redefined. When cookies are set, the visitor must first be asked whether they want to allow this. For this reason, Google Analytics may no longer be integrated directly into the page.

The remedy is the WordPress premium plugin Borlabs Cookie.

image 62
WordPress Cookie Double-Opt-in using Borlabs Cookie
image 63
Detail view of Borlabs Cookies popup

Install the plugin to start integrating Google Analytics into WordPress. After the installation, go directly to Borlab’s Cookies and enter your license first. After that, all settings options are available to you.

image 61
Embed WordPress Google Analytics with Borlabs Cookies

To integrate Google Analytics, you now have to switch to the Cookies tab. Then scroll down to the Marketing item and click on the Add new button.

image 65
Borlabs Cookie Marketing Add Cookie Opt-in

After that, you just need to choose the appropriate service. This is already supplied by Borlabs Cookies as a template.

image 66
Embed Google Analytics on WordPress with Borlabs Cookies

The template already contains all information about the provider, the cookies and the runtime. All you have to do now is enter your tracking ID in the additional settings.

image 67
Google Analytics tracking ID stored in Borlabs cookie

Afterwards you save the whole thing and the integration is already finished.

Now you just need to change the status of Borlab’s cookie to show the pop-up. You can find the option for this in the Settings tab.

It is advantageous that Borlabs Cookie is already delivered with standard texts. Further adjustments are therefore optional for the time being.

image 64
Borlabs Cookie – Customize status to enable the pop-up.

As soon as you reopen your page, the pop-up will appear. The Google Analytics script we added above will be loaded only after confirmation.

Disable old Google Analytics integrations #

After you have integrated Google Analytics with Borlabs Cookie into WordPress, you should definitely remember to remove old integrations.

The best way to do this is to first check the WordPress Plugin Manager to see if you have installed another plugin for statistics, such as Google Analytics. Normally it is enough to deactivate the plugin to remove the script.

In some cases, the script may also have been integrated directly into your theme. Therefore, you should check your theme options as well.

Another method was to integrate the script directly into the WordPress header. Therefore, you should also check whether Google Analytics was possibly deposited there.

Check if Google Analytics was loaded without opt-in #

Thanks to Google Chrome’s development console, you can find out in no time if Google Analytics is loading without consent.

Don’t feel like reading? Then take a look at our video tutorial:

YouTube

Mit dem Laden des Videos akzeptieren Sie die Datenschutzerklärung von YouTube.
Mehr erfahren

Video laden

The best way to do this is to switch to Chrome’s incognito mode. You can open this mode with the key combination Ctrl+Shift+N.

After that, simply open your website. If you did everything correctly, you should now see the cookie opt-in pop-up from Borlabs.

image 68
Borlabs Cookie Opt-in for Google Analytics

Ignore the pop-up and open the development console of your browser with the F12 key.

Then switch to the Application tab.

On the left side, you will find an entry named Cookies under Storage. Expand this entry by clicking on the arrow. There you should see the domain of your website. Click on it.

On the right side, you will now find a list of all cookies set by your website.

Ideally, this list is empty.

image 69
Google Chrome Developer Console for Cookies

However, if you see entries like these, some plugin, theme or manually added code is unintentionally loading Google Analytics. Therefore, you should start searching to find out which script is responsible for this.

image 70
Google Analytics cookies in the Chrome developer console

Google Analytics and privacy #

Since the introduction of the GDPR, some precautions have to be taken to be able to use Google Analytics on your site:

  1. Conclude order processing agreement with Google:
    You can do this quickly and easily via your Google Analytics account. You can find instructions in the Google Analytics Help.
  2. Anonymize IP:
    Next, you should enable IP address anonymization. To do this, you just need to add the following to the script:
    gtag(“config”, “%%trackingId%%”, { “anonymize_ip”: true });
    If you are using Borlab’s cookie, this line should already be there. To be on the safe side, you should still check it.
  3. Do not use “User ID function”:
    Unfortunately, this feature is not privacy compliant. You should therefore not use it.
  4. Opt-out Cookie integrieren:
    In addition to the opt-in, you must of course also offer your visitors to manually deactivate the collection of data. You can read how this works in Google’s user opt-out article.

  5. Limit retention of user and event data:
    Google Analytics offers you the possibility to determine the duration of the data storage yourself. You can find this in your settings under Tracking information / Data retention. The storage period should not be longer than 12-14 months. Also disable the Reset on new activity option.

  6. Customize privacy policy:
    Don’t forget to also fully inform your visitors in the privacy policy if and how you use Google Analytics. Here you should also refer to the opt-out.
Hier klicken, um den Beitrag zu bewerten
[Gesamt: 0 Durchschnitt: 0]

Leave A Comment

Title