Skip to main content

Overview

The ConsentPlugin gates event tracking behind user consent, helping you comply with GDPR, CCPA, and other privacy regulations.

Installation

Options

boolean
default:"true"
When true, all event tracking is paused until consent is granted.
Callback fired when an event is attempted but consent hasn’t been granted. Use this to show your consent UI.

Methods

grant()

Grant consent and start tracking:
When called:
  • Event tracking resumes immediately
  • Queued events are sent
  • Consent state is persisted in localStorage

deny()

Deny consent and disable tracking:
When called:
  • Event tracking is disabled
  • Queued events are discarded
  • Consent state is persisted

getStatus()

Check current consent status:

reset()

Clear consent state (user can be asked again):

Complete Implementation

When consent is required but not yet granted: After consent is granted, queued events are sent and identity is persisted.

OneTrust Integration

Cookiebot Integration

Custom CMP Integration

Persistence

Consent state is stored in localStorage under refine_consent:
The consent persists across sessions until:
  • User clears browser data
  • You call consentPlugin.reset()
  • User explicitly changes their preference

Privacy Configuration

Combine with SDK privacy settings:

Next Steps

Debug Plugin

Development tools

Auto Track Plugin

Automatic tracking