Support » Plugin: Google Analytics Opt-Out (DSGVO / GDPR) » Make opt out JavaScript function available globally

  • Hi,
    great plugin!

    Please consider making the gaoo_handle_optout() function available on every page (for example in the footer). The reason is that sometimes it’s necessary to access it from third party scripts (like cookie consent management plugins) to provide a quick way to handle opt in/opt out functionality.

    Also, you probably should minify the JavaScript code.

    What do you think? Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Schweizer Solutions GmbH

    (@schweizersolutions)

    Hi Philipp,

    thank you for the feature request!

    You’ll find this in our next update. We added a local storage support as a fallback for the cookie. That’s why we had to store the code in a separate file, of course minified 😉

    Hi @schweizersolutions,

    You’ll find this in our next update.

    In v1.3 gaoo_handle_optout() still doesn’t seem to be available globally, because the JavaScript file is only enqueued on the privacy page.

    If you do not want to enqueue it on all pages, at least please consider setting up $json_data variable in a independet method. This would allow third party scripts to enqueue the script when needed like this:

    $json_data = GAOO_Public::json_data();
    wp_localize_script( 'gaoo-public', 'gaoo_data', $json_data );
    wp_enqueue_script( 'gaoo-public' );

    Thanks!

    Plugin Author Schweizer Solutions GmbH

    (@schweizersolutions)

    Hi @tyrannous,

    yes, you are right. We have implemented your suggestion and will release it in the next update.

    The code will be:

    
    $json_data = GAOO_Utils::get_json();
    
    if ( ! empty( $json_data ) ) {
      wp_localize_script( 'gaoo-public', 'gaoo_data', $json_data );
      wp_enqueue_script( 'gaoo-public' );
    }		
    

    Thank you 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Make opt out JavaScript function available globally’ is closed to new replies.