Title: webwart's Replies | WordPress.org

---

# webwart

  [  ](https://wordpress.org/support/users/webwart/)

 *   [Profile](https://wordpress.org/support/users/webwart/)
 *   [Topics Started](https://wordpress.org/support/users/webwart/topics/)
 *   [Replies Created](https://wordpress.org/support/users/webwart/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/webwart/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/webwart/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/webwart/engagements/)
 *   [Favorites](https://wordpress.org/support/users/webwart/favorites/)

 Search replies:

## Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Analytics Germanized for Google Analytics (GDPR / DSGVO)] Opt-Out Cookie funktioniert offenbar bei Chrome nicht](https://wordpress.org/support/topic/opt-out-cookie-funktioniert-offenbar-bei-chrome-nicht/)
 *  Thread Starter [webwart](https://wordpress.org/support/users/webwart/)
 * (@webwart)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/opt-out-cookie-funktioniert-offenbar-bei-chrome-nicht/#post-10560916)
 * Ich hab mal ein wenig umgebaut, so dass die Shortcodes und damit die Auswertung
   des Opt-out-Cookies frühzeitiger (im Head) eingebunden werden und auch noch eine
   Änderung in den Einstellungen eingebaut die es erlaubt zu sagen, dass wenn das
   Cookie gesetzt wurde, dass dann gar kein Code mehr eingebaut wird. Wobei noch
   die Label-Übersetzungen fehlen 😉 War mehr ein Proof-Of-Concept.
 * Ich weiß nicht genau, wie ich euch das am Besten zukommen lassen kann, ich poste
   hier mal den kompletten SVN-Diff:
 *     ```
       Index: ga-germanized.php
       ===================================================================
       --- ga-germanized.php	(Revision 1919995)
       +++ ga-germanized.php	(Arbeitskopie)
       @@ -22,7 +22,7 @@
        define('PBGAG_FILE', __FILE__);
        define('PBGAG_DIR', dirname(__FILE__));
        define('PBGAG_BASE', plugin_basename(__FILE__));
       -define('PBGAG_VERSION', '1.4.0');
       +define('PBGAG_VERSION', '1.4.1');
   
        if( ! class_exists('gaGermanized') ):
   
       @@ -50,6 +50,17 @@
        				)
        			);
   
       +			/*
       +			 * Shortcodes und Opt-out js
       +			 */
       +			 add_action(
       +				'init',
       +				array(
       +					'gag_shortcodes',
       +					'init'
       +				)
       +			);
       +
        			if( is_admin() ) {
   
        				add_action(
       @@ -126,13 +137,6 @@
   
        			} // end else if( is_admin() )
   
       -			add_action(
       -				'init',
       -				array(
       -					'gag_shortcodes',
       -					'init'
       -				)
       -			);
        		}
   
        		public static function detect_plugin_activation( $plugin, $network_activation )
       Index: inc/gag_analytics.php
       ===================================================================
       --- inc/gag_analytics.php	(Revision 1919995)
       +++ inc/gag_analytics.php	(Arbeitskopie)
       @@ -58,10 +58,27 @@
        				return false;
        			}
   
       -
        			return true;
        		}
   
       +		public static function ga_is_disabled_by_cookie() {
       +			// Init Settings
       +			if( ! self::$settings ) {
       +				self::init();
       +			}
       +
       +			$ga_cookie_name = 'ga-disable-' .esc_attr(self::$uaid);
       +
       +			// ga-disable Cookie
       +			if( isset($_COOKIE[$ga_cookie_name]) ) {
       +				$ga_disable_cookie = $_COOKIE[$ga_cookie_name];
       +			} else {
       +				$ga_disable_cookie = false;
       +			}
       +
       +			return (self::$settings['ga-remove-on-cookie'] && $ga_disable_cookie);
       +		}
       +
        		public static function gst()
        		{
        			$config = array();
       @@ -153,13 +170,16 @@
        			self::init();
   
        			if( ! empty( self::$uaid ) && self::is_analytics_allowed() ) {
       +				if (!self::ga_is_disabled_by_cookie()) {
   
       -				if( self::$mode === 'ua' ) {
       -					echo self::ua();
       +					if( self::$mode === 'ua' ) {
       +						echo self::ua();
       +					} else {
       +						echo self::gst();
       +					}
        				} else {
       -					echo self::gst();
       +					echo '<!-- Google Analytics disabled by user request (cookie) -->';
        				}
       -
        			} else {
        				echo '<!-- Missing Google Analytics ID or Analytics Integration disabled -->';
        			}
       Index: inc/gag_settings_handler.php
       ===================================================================
       --- inc/gag_settings_handler.php	(Revision 1919995)
       +++ inc/gag_settings_handler.php	(Arbeitskopie)
       @@ -156,6 +156,18 @@
        					)
        				),
   
       +                'ga-remove-on-cookie' => array(
       +					'name'      => 'ga-remove-on-cookie',
       +					'default'   => 0,
       +					'required'  => false,
       +					'min_l'     => 0,
       +					'max_l'     => 1,
       +					'values'    => array(
       +						0,
       +						1
       +					)
       +				),
       +
                        /**
                         * Cookie Consent
                         * *************************************
       Index: inc/gag_shortcodes.php
       ===================================================================
       --- inc/gag_shortcodes.php	(Revision 1919995)
       +++ inc/gag_shortcodes.php	(Arbeitskopie)
       @@ -40,7 +40,7 @@
        				plugins_url(dirname(PBGAG_BASE)).'/assets/js/gaoptout.js',
        				array('jquery'),
        				PBGAG_VERSION,
       -				true
       +				false
        			);
   
        			wp_localize_script(
       Index: inc/tpl/options_page.php
       ===================================================================
       --- inc/tpl/options_page.php	(Revision 1919995)
       +++ inc/tpl/options_page.php	(Arbeitskopie)
       @@ -204,6 +204,25 @@
   
                            </div>
   
       +                    <div class="gag-settings-item subheadline clear">
       +                        <span><?php esc_html_e('Remove Google Analytics completely after Opt-out', 'ga-germanized') ?></span>
       +
       +                        <div class="oneline_field checkboxarea clear">
       +                            <div class="leftbox">
       +                                <strong><?php esc_html_e('Remove Google Analytics completely after Opt-out', 'ga-germanized') ?></strong>
       +                            </div>
       +
       +                            <div class="rightbox">
       +                                <input type="checkbox" name="ga-remove-on-cookie" id="ga-remove-on-cookie" value="1" <?php checked(1, $settings['ga-remove-on-cookie']) ?> />
       +
       +                                <label for="ga-remove-on-cookie" class="checkboxlabel"><?php esc_html_e('Remove google-analytics code completely if user sends the "ga-disable-UA-XXXXXX-Y" cookie.', 'ga-germanized') ?></label>
       +
       +                                <p class="mini-description"><?php _e('Remove google-analytics code completely if user sends the "ga-disable-UA-XXXXXX-Y" cookie.', 'ga-germanized') ?></p>
       +                            </div>
       +                        </div>
       +
       +                    </div>
       +
                            <div class="gag-analytics-sendmebutton">
                                <button type="submit" class="gag-sendme-up"><?php esc_html_e('Save Changes', 'ga-germanized') ?></button>
                            </div>
       ```
   
 * Viele Grüße
    Webwart
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Analytics Germanized for Google Analytics (GDPR / DSGVO)] Opt-Out Cookie funktioniert offenbar bei Chrome nicht](https://wordpress.org/support/topic/opt-out-cookie-funktioniert-offenbar-bei-chrome-nicht/)
 *  Thread Starter [webwart](https://wordpress.org/support/users/webwart/)
 * (@webwart)
 * [7 years, 9 months ago](https://wordpress.org/support/topic/opt-out-cookie-funktioniert-offenbar-bei-chrome-nicht/#post-10551789)
 * Hallo Pascal,
 * sorry, dass ich jetzt erst antworte. Es handelt sich um [https://female-founder-academy.de](https://female-founder-academy.de)
 * Ich konnte das Problem temporär lösen, indem ich die Auswertung von den Opt-out
   Cookie manuell in den Header geschrieben habe. Dann kommt die Auswertung offenbar
   früher dran.
 * Vielen Dank und viele Grüße
    Webwart
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Analytics Germanized for Google Analytics (GDPR / DSGVO)] Ausgehendes Link tracking verhindert target=”_blank”](https://wordpress.org/support/topic/ausgehendes-link-tracking-verhindert-target_blank/)
 *  Thread Starter [webwart](https://wordpress.org/support/users/webwart/)
 * (@webwart)
 * [7 years, 12 months ago](https://wordpress.org/support/topic/ausgehendes-link-tracking-verhindert-target_blank/#post-10287654)
 * Hallo Pascal,
 * Webwart ist prima, danke 🙂
 * Ich habe gesehen, dass in meinem Codeschnipsel auf jeden Fall mindestens schon
   ein Fehler drin ist (ich konnte den leider immer noch nicht wirklich testen):
 * Anstatt `if ($target != '_blank') {` muss es `if ($linkTarget != '_blank') {`
   heißen.
 * Ich hoffe, der Rest funktioniert wenigstens 😉
 * Ansonsten könnte man natürlich auch einfach in Abhängigkeit von dem Link-Target
   den Callback von `function() { document.location = url; };` auf `function() {`
   window.open(url, ‘_blank’);` ändern. Wäre ja auch eigentlich ne schöne Variante.
 * Viele Grüße, vielen Dank und einen schönen Abend noch!
    Webwart
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Analytics Germanized for Google Analytics (GDPR / DSGVO)] Ausgehendes Link tracking verhindert target=”_blank”](https://wordpress.org/support/topic/ausgehendes-link-tracking-verhindert-target_blank/)
 *  Thread Starter [webwart](https://wordpress.org/support/users/webwart/)
 * (@webwart)
 * [7 years, 12 months ago](https://wordpress.org/support/topic/ausgehendes-link-tracking-verhindert-target_blank/#post-10287028)
 * Hallo Pascal,
 * Ok, ich versteh das Problem…
 * Ich seh eigentlich nur zwei Varianten:
    1. Eine Unterscheidung im Javascript,
   ungefähr so:
 *     ```
       var $trackOutboundLink_ga = function(url, callback)
       {
           ga('send', 'event', 'outbound', 'click', url, {
               'transport': 'beacon',
               'hitCallback': callback
           });
       };
   
       var $trackOutboundLink_gtag = function(url, callback)
       {
           gtag('event', 'click', {
               'event_category': 'outbound',
               'event_label': url,
               'transport_type': 'beacon',
               'event_callback': callback
           });
       };
   
       $('a:not([href^="' + gagTracker.url + '"], [href^="#"])').on('click', function (e) {
          var $linkTarget = $(this).attr('target');
          var $url = $(this).attr('href');
   
          var $callback;
   
          if ($target != '_blank') {
             e.preventDefault();
             $callback = function() { document.location = url; };
          }
   
          if (gagTracker.mode == 'ua') {
             $trackOutboundLink_ga($url, $callback);
          } else {
             $trackOutboundLink_gtag($url, $callback);
          }
       });
       ```
   
 * // ACHTUNG: Ich habe den Code so nicht getestet 😉
 * 2. Zwei unterschiedliche onClick-Handler, die dann anhand der Bedingung für den
   Link rangeschrieben werden. Die Bedingung müsste dann noch die Prüfung beinhalten,
   ob das target != ‘_blank’ ist oder nicht.
 * Ich bin leider nicht so firm in den jQuery Selektoren, aber es müsste wie bisher
   verodert die beiden Bedingung zur URL besitzen und verundet die Bedingung mit
   dem Target.
 * Viele Grüße,
    Webwart
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Analytics Germanized for Google Analytics (GDPR / DSGVO)] Ausgehendes Link tracking verhindert target=”_blank”](https://wordpress.org/support/topic/ausgehendes-link-tracking-verhindert-target_blank/)
 *  Thread Starter [webwart](https://wordpress.org/support/users/webwart/)
 * (@webwart)
 * [8 years ago](https://wordpress.org/support/topic/ausgehendes-link-tracking-verhindert-target_blank/#post-10283723)
 * Meine kurze Analyse 😉
 * Ist eigentlich alles in der gag-tracker.js drin.
 * Das e.preventDefault() sorgt dafür, dass sich das neue Fenster nicht öffnet.
   
   Der Erfolgscallback nach dem Tracking öffnet die URL im gleichen Fenster.
 * Kommentiere ich das preventDefault() aus und ersetze den Callback durch ein console.
   log(“success”) funktioniert alles wie ich es erwartet hätte.
 * Ich hoffe, das hilft weiter und man kann vielleicht was ändern oder das Verhalten
   einstellbar machen?
 * Viele Grüße!

Viewing 5 replies - 1 through 5 (of 5 total)