The official WordPress Plugin Site Kit from Google shows you a lot of useful information about your website and your visitors and can be easily linked to Google Analytics and Co. In order to use the plugin on your website in compliance with GDPR, we will show you in this article how you can block it using Borlabs Cookies Script Blocker in order to obtain consent via the Cookies. Let's get started.
Step 1: Add Script Blocker
From the Borlabs Cookie menu, click Script Blocker, then click Add New.
Define Page and Search Phrase
To make the work easier, enter the word google_gtagjs in the Search phrases field.
Google Site Kit integrates the JavaScript for Google Analytics via Google Tag Manager. The JavaScript for this is registered in WordPress with the handle google_gtagjs.
Scanning
Hast du alles so eingetragen wie im Bild oben, klicke auf Scannen. Borlabs Cookie wird jetzt deine Website nach JavaScript durchsuchen und das JavaScript hervorheben, in denen die Suchphrase gefunden wurde. Wenn Borlabs Cookie mit dem Scannen fertig ist, erhältst du eine Meldung wie unten im Bild gezeigt und musst auf Weiter klicken.
Once you have entered everything as in the picture above, click on Scan. Borlabs Cookie will now scan your website for JavaScript and highlight the JavaScript in which the search phrase was found. When Borlabs Cookie has finished scanning, you will receive a message as shown in the image below and must click Next.
Konfigurieren
Nachdem deine Seite gescannt wurde und du auf Weiter geklickt hast, musst du eine ID und Namen für deinen Script Blocker festlegen.
Für ID gibst google-site-kit an und als Namen Google Site Kit. Den Status kannst du gleich auf AN setzen.
Choose JavaScript to Block
Scroll down a little bit to Matching JavaScript handles. Our search phrase found the right JavaScript and provided it for blocking.
Click on Create Script Blocker to create the Script Blocker. After the saving was successful, you will receive information about the blocked JavaScript handle and the set phrases that should block the JavaScript in which the phrases occur (in this case none).
Once a Script Blocker is created, you can no longer add or remove JavaScript handles and phrases. If you want to make a change, delete the Script Blocker and create it again.
Scroll down a little to Unblock Code. The Script Blocker from Borlabs Cookie gives you two different unlock codes, one for cookies and one for content blocker, which allows you to unblock the blocked JavaScript. Click on the clipboard icon to copy the JavaScript from For Cookies.
Step 2: Create Cookie
It's nearly done. Click on Cookies in Borlabs Cookie and then on Add New in the Cookie Group Statistics.
In Services, select Google Analytics and click Next.
Borlabs Cookie fills in all necessary data. Scroll down to Additional settings and enter something in the Tracking ID field. This field is mandatory, but we don't need it.
Under Opt-in Code, insert the code (remove the existing code first) that you have just copied from the For Cookies field in the Script Blocker.
<script>window.BorlabsCookie.unblockScriptBlockerId("google-site-kit");</script>
After inserting the code, click on Save all settings. Done.
Google Site Kit is now initially blocked and only if the visitor agrees to the Cookie for Google Analytics will Google Site Kit be unblocked and tracking takes place.
Please check in Google Analytics under Data Settings > User and event data Retention > Event data retention which retention period is selected.
This should match the information in Borlabs Cookie (option: Cookie duration). If you select e.g. 14 months in Google Analytics, you simply have to change this in the Cookie settings under "Cookie duration".
If you have added your measurement ID and, if necessary, the cookie runtime in the cookie settings and saved all settings, you have successfully set up Google Analytics.