开发者 | schweizersolutions |
---|---|
更新时间 | 2024年4月9日 23:45 |
捐献地址: | 去捐款 |
PHP版本: | 7.0 及以上 |
WordPress版本: | 6.5 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
Plugins > Install
Opt-Out for Google Analytics
opt-out-for-google-analytics
into the /wp-content/plugins/
directory of your WordPress installationThe Data Protection Regulation (DSGVO, EU-DSGVO, GDPR) stipulates that a website visitor must have the option to object to the collection of data by Google Analytics. Until now, this was only possible via browser addon, or complicated JavaScript code integrations on the own website. With this plugin, this is very easy and the user also has the option to undo the objection.
Yes, because we also comply with Google's specifications. More information about the guidelines: https://developers.google.com/analytics/devguides/collection/analyticsjs/user-opt-out
This plugin can also be used if the tracking code was inserted manually at the theme or with the help of a plugin.
Yes, it is recommended to offer the opt-out for Google Analytics in the privacy policy. Keeping track of all the GDPR legislative changes is not easy. Especially not next to your core business. That's why we offer you a data protection generator with our partner easyRechtssicher. The privacy policy is created ONCE and automatically kept up to date in WordPress itself. No more filling out forms again and copying and pasting privacy statements onto the site, it runs completely automated. More info here: https://schweizer.solutions/datenschutzgenerator
If the site visitor clicks on the opt-out link to disable Google Analytics for him, then a cookie is set. With this cookie, the system knows that this site visitor should not be tracked on the website. This cookie is only valid in the browser with which the site visitor was on the website and clicked on the opt-out link. If the visitor uses a different browser, he would have to click on the link again. If the site visitor clears his browser data (cookies, download history, etc.), the cookie is also deleted and the site visitor would have to click on the opt-out link again.
You can deactivate the status of the plugin under "Settings > GA Opt-Out", there you only have to uncheck "Activate opt-out function". You can deactivate the whole plugin under "Plugins > Installed Plugins" by clicking on "Deactivate" for the "Opt-Out for Google Analytics" Plugin. After deactivating the plugin, you can remove it completely by clicking on "Delete".
You can use the shortcode [gaoo_optout]
in posts, pages and widgets (text widget).
Yes, you can. For this purpose we have included appropriate filters and action hooks. `// Before the shortcode is resolved add_action( 'gaoo_before_shortcode', 'my_before_shortcode', 10, 2); function my_before_shortcode( $tracking_code, $current_status ) { // $tracking_code - The current used tracking code "UA-XXXXX-Y" OR "G-XXXXXXXXXX" // $current_status - The current status of the page visitor: activate or deactivate } // After the shortcode is resolved add_action( 'gaoo_after_shortcode', 'my_after_shortcode', 10, 2); function my_after_shortcode( $tracking_code, $current_status ) { // $tracking_code - The current used tracking code "UA-XXXXX-Y" OR "G-XXXXXXXXXX" // $current_status - The current status of the page visitor: activate or deactivate } // Before the JS code, to disable GA, is issued add_action( 'gaoo_before_head_script', 'my_before_script', 10, 1); function my_before_script( $tracking_code ) { // $tracking_code - The current used tracking code "UA-XXXXX-Y" OR "G-XXXXXXXXXX" } // After the JS code, to disable GA, is issued add_action( 'gaoo_after_head_script', 'my_after_script', 10, 1); function my_after_script( $tracking_code ) { // $tracking_code - The current used tracking code "UA-XXXXX-Y" OR "G-XXXXXXXXXX" } // The UA-Code used add_filter( 'gaoo_get_ua_code', 'my_ga_tracking_code', 10, 2 ); function my_ga_tracking_code( $tracking_code, $ga_plugin ) { // $tracking_code - The current used tracking code "UA-XXXXX-Y" OR "G-XXXXXXXXXX" // $ga_plugin - Selected source for the tracking code } // Whether the page should be reloaded after the click add_filter( 'gaoo_force_reload', 'my_force_reload', 10, 1); function my_force_reload( $force ) { // $force - "true" = force reload; "false" = do not reload } `
It happens that some self-developed themes do not resolve shortcodes and the plugin does not work.
To execute the shortcode anyway, you have to use this code in the theme, at the desired position:
echo do_shortcode('[ga_optout]');
If the settings have been changed, e.g. in a compatible Google Analytics tracking plugin, then this change will only be noticed during the autom. check (weekly). It is possible to perform the check beforehand. To do this, the "Save changes" button would have to be clicked under "Settings > GA Opt-Out". This will read the new settings and save them for a week until the next automatic check.
The JavaScript event gaoptout
is fired on the window
object, which can be reacted to.
If the page visitor clicks on the link to perform an opt-out, then a false
is passed as the value. If the visitor performs an opt-in, then a true
is passed.
Example code:
jQuery(window).on('gaoptout', function (e) { console.log(e.detail); });
You have the possibility to change the appearance of the link via CSS in the settings of the plugin. For this purpose, the following CSS classes are available:
The link itself:
#gaoo-link { ... }
The link if the page visitor has disagreed with the tracking:
.gaoo-link-activate { ... }
The link if the page visitor has NOT disagreed with the tracking:
.gaoo-link-deactivate { ... }
You can enter several recipient addresses, separated by a comma, into the input field for the e-mail, which should receive the status message.
Example: webmaster@example.org,admin@example.org,dev@example.org
The status check runs in the set interval and only sends e-mails if at least one status is set to red. If you still do not receive any e-mails, it can have the following causes:
The opt-out cookie is set according to Google's specifications. Thus, the GTM (Google Tag Manager) should not need to be adjusted. However, if the Google Analytics code is not loaded at all, the GTM must check whether the cookie is set or whether the value in the "HTML5 Local Storage" is set accordingly. On this basis, it can be decided in the GTM whether the code should be loaded or not. If no entry or cookie is present, then no opt-out has taken place. This is also the case if the value "false" is returned. The opt-out has only taken place if the value "true" is returned. Specific cookie, with the corresponding tracking code: ga-disable-UA-XXXXX-YY or ga-disable-G-XXXXXXXXX Generic Cookie: ga-opt-out Specific entry in the HTML5 Local Storage: ga-disable-UA-XXXXX-YY or ga-disable-G-XXXXXXXXX Generic entry in the HTML5 Local Storage: ga-opt-out
The use of this plugin is at your own risk. The website operator must be able to ensure the functionality of the plugin itself. To do this, it must be checked, among other things, whether after clicking on the link, a cookie in this format was set: ga-disable-UA-XXXXXXXX-YY Supporting, for the Google Tag Manager, another cookie with the name "ga-opt-out" is set.