Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chavesm/9ff2876b4e4f8468fc22dec959eb26a7 to your computer and use it in GitHub Desktop.
Save chavesm/9ff2876b4e4f8468fc22dec959eb26a7 to your computer and use it in GitHub Desktop.
Use MonsterInsights filter hook to set Didomi Web API attributes to control tracking based on visitor consent.
<?php // This line is not needed for functions.php.
function monsterinsights_eu_compliance_tracking_didomi( $attributes ) {
$attributes['data-vendor'] = "didomi:google";
$attributes['type'] = "didomi/javascript";
return $attributes;
}
add_filter( 'monsterinsights_tracking_analytics_script_attributes', 'monsterinsights_eu_compliance_tracking_didomi' );
/** Add this PHP filter hook to your child theme's functions.php file or use a plugin like Code Snippets. */
/**
Consult Didomi developers docs for specifics:
https://developers.didomi.io/cmp/web-sdk/third-parties/custom-integrations/no-tag-manager
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment