MonsterInsights is with over 12 million installations one of the best and most popular WordPress plugins for Google Analytics. To keep using this popular plugin, we will show you in this article how you can use Borlabs Cookie Script Blocker to block the cookies to get your consent. Let's get started.
Step 1: Add Script Blocker
From the Borlabs Cookie menu, click Script Blocker and then click Add New.
Specify Page And Search Phrase
Next, you need to select a page to scan for JavaScript. Since MonsterInsights is active on all pages, you can select any page here. In this case we have chosen our homepage.
To make the work easier, enter the words mi_version, googletagmanager and __gtag in the Search phrases field and separate both words with a comma.
Scan
The setting can be found under Insights > Settings > Advanced. The Administrator role must be removed under Exclude These User Roles From Tracking.
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 phrases were found. When Borlabs Cookie has finished scanning, you will receive a message as shown in the image below and you must click Next.
Configuring
After your page has been scanned and you have clicked Next, you must set an ID and Name for your Script Blocker.
For ID specify monster-insights and as name MonsterInsights. You can set the Status to ON.
Select JavaScript to block
Scroll down a bit to Matching handles and JavaScripts. Our search phrases found the correct JavaScripts to block.
Click Create Script Blocker to create the Script Blocker. After the saving was successful, you will get an information about the blocked JavaScript handles and the set phrases to block the JavaScript in which the phrases occur.
Once a Script Blocker is created, you cannot 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 of Borlabs Cookie gives you two different unlock codes, one for cookies and one for content blockers, which allow 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.
Under 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. In addition, the "Prioritize" function must be deactivated.
Under Opt-in Code, paste the code (remove the existing code first) that you just copied from the For Cookies field in Script Blocker.
If you have the same look as in the picture, you can click on Save all settings. Done.
MonsterInsights is now initially blocked and only if the visitor agrees to the cookie for Google Analytics, MonsterInsights is unblocked and tracking takes place.
MonsterInsights
You don't have MonsterInsights yet? Here you can buy MonsterInsights.1
MonsterInsights®is a registered trademark of MonsterInsights, LLC.
1Affiliate Link