To make your Opt-Out-Link for Google Analytics work in WordPress:
- Use the text mode of the WordPress Editor.
- Place a normal URL as a placeholder link first.
- Replace URL in the generated HTML link with JS call.
- Make sure that the actual opt-out script is in the source test before the JS call.
Websites that use Google Analytics must give their visitors the opportunity to opt out by mid-2019. This means that there must be a link that, if clicked, deactivates Google Analytics Tracking for exactly this user and browser. From a technical point of view, a cookie is usually set in which the user’s wish not to be tracked is documented and then taken into account by the tracking script.
In order for the whole thing to work, the actual opt-out script must be loaded in the header or in any case before the opt-out link mentioned below. Google itself pretends how the opt-out script should look like.
Test if the opt-out link works
However, website operators are well advised to check immediately after implementation and also at regular intervals whether the opt-out link for Google Analytics still works at all on their own website. Unfortunately, the WordPress editor has the peculiarity that when saving links that do not contain normal URLs, but Javascript calls, for example, are disabled.
And so, of all things, the dutiful regular maintenance and amendment of one’s own data protection declaration can lead to the Analytics Opt Out no longer working. When clicking, a message must appear confirming that tracking has been deactivated. In addition, a cookie must be set to prevent tracking by Google Analytics. This can be checked with the browser’s developer tools. Experience shows: This is not the case with many WordPress websites. They do have an opt-out link, but it does not work.
Video: How to set the opt-out link for Google Analytics in WordPress correctly
Due to current events, we have recorded in a two-minute video how it can be ensured that the Google Analytics opt-out in the privacy statement still works even after a change / renewed saving.