Read consent from your own code

Check a category in JavaScript and react when the visitor changes their mind.

  • Reference
  • AriConsent
  • 1 min read
  • Updated
if ( window.ariconsent.has( 'statistics' ) ) {
  // load your statistics script
}
document.addEventListener( 'ariconsent:change', function () {
  // the visitor changed their choice
} );

The categories are preferences, statistics and marketing.

Plugins that read consent through the WP Consent API follow the visitor's choice automatically. In Google Tag Manager, use the ariconsent_update dataLayer event.

The browser stores one first-party cookie, ariconsent, with the consent ID, time, policy revision and chosen categories.

Still stuck?

Our helpdesk answers on working days, Norwegian time. Include your WordPress version, PHP version and the page address.

Submit a ticketor email info@arihub.com