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.
() => void
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:- Event tracking resumes immediately
- Queued events are sent
- Consent state is persisted in localStorage
deny()
Deny consent and disable tracking:- 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
Consent Banner HTML
Behavior Before Consent
When consent is required but not yet granted:
After consent is granted, queued events are sent and identity is persisted.
Integration with Cookie Consent Tools
OneTrust Integration
Cookiebot Integration
Custom CMP Integration
Persistence
Consent state is stored in localStorage underrefine_consent:
- User clears browser data
- You call
consentPlugin.reset() - User explicitly changes their preference
Testing Consent Flow
Privacy Configuration
Combine with SDK privacy settings:Next Steps
Debug Plugin
Development tools
Auto Track Plugin
Automatic tracking