Support » Plugin: GDPR Cookie Compliance (CCPA, PIPEDA ready) » Any suggestion on how to organize loading of third party scripts?

  • Resolved filoveg

    (@filoveg)


    This is perhaps unrelated but do you have any suggestion how to disable and only conditionally load third party scripts depending on user selection? Even some link for a tutorial or anything would be helpful.

    I am wondering for conditionally including social shares, Facebook and other JS code, usually we all rely on other WordPress plugins. We could dequeue those scripts with PHP but then we can’t load them again with your plugin if user choses to enable cookies.

    Also is there a possibility to use something like a WordPress filter to conditionally load code instead of placing it directly inside your plugin’s admin?

Viewing 1 replies (of 1 total)
  • Hi There,

    Thanks for your comments.

    We have implemented hooks to implement custom scripts by php based on the user preferences, check the hooks below:

    HOOK to GDPR custom 3RD-PARTY script by php – HEAD

    add_action('moove_gdpr_third_party_header_assets','moove_gdpr_third_party_header_assets');
    function moove_gdpr_third_party_header_assets( $scripts ) {
    	$scripts .= '<script>console.log(“third-party-head”);</script>';
    	return $scripts;
    }

    HOOK to GDPR custom 3RD-PARTY script by php – BODY

    add_action('moove_gdpr_third_party_body_assets','moove_gdpr_third_party_body_assets');
    function moove_gdpr_third_party_body_assets( $scripts ) {
    	$scripts .= '<script>console.log(“third-party-body”);</script>';
    	return $scripts;
    }

    HOOK to GDPR custom 3RD-PARTY script by php – FOOTER

    add_action('moove_gdpr_third_party_footer_assets','moove_gdpr_third_party_footer_assets');
    function moove_gdpr_third_party_footer_assets( $scripts ) {
    	$scripts .= '<script>console.log(“third-party-footer”);</script>';
    	return $scripts;
    }

    HOOK to GDPR custom ADVANCED-PARTY script by php – HEAD

    add_action('moove_gdpr_advanced_cookies_header_assets','moove_gdpr_advanced_cookies_header_assets');
    function moove_gdpr_advanced_cookies_header_assets( $scripts ) {
    	$scripts .= '<script>console.log(“advanced-head”);</script>';
    	return $scripts;
    }

    HOOK to GDPR custom ADVANCED-PARTY script by php – BODY

    add_action('moove_gdpr_advanced_cookies_body_assets','moove_gdpr_advanced_cookies_body_assets');
    function moove_gdpr_advanced_cookies_body_assets( $scripts ) {
    	$scripts .= '<script>console.log(“advanced-body”);</script>';
    	return $scripts;
    }

    HOOK to GDPR custom ADVANCED-PARTY script by php – FOOTER

    add_action('moove_gdpr_advanced_cookies_footer_assets','moove_gdpr_advanced_cookies_footer_assets');
    function moove_gdpr_advanced_cookies_footer_assets( $scripts ) {
    	$scripts .= '<script>console.log(“advanced-footer”);</script>';
    	return $scripts;
    }

    However, the hooks above doesn’t touch other plugins, and will be added by javascript, so you can’t include php here. My suggestion is, if possible, remove all the plugins creating cookies on your site and add the scripts by GDPR plugin

    I hope this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘Any suggestion on how to organize loading of third party scripts?’ is closed to new replies.