To comply with privacy regulations such as GDPR and CCPA, your application must provide users with the ability to opt out of data tracking. The MoEngage Web SDK provides APIs to disable user-specific data collection while maintaining core functionality and anonymous analytics.
- By default, data tracking is enabled.
- When a user opts out, the SDK stops collecting personally identifiable information (PII) and behavior-specific data.
How Data Tracking Opt-out Works
When you disable data tracking, the SDK performs the following actions to ensure compliance and privacy:
- Data Erasure (Local): Deletes existing user attributes, events, session information, and batches from local storage.
- State Persistence: Maintains the opt-out preference across browser sessions and user logouts.
- Anonymous Tracking: Continues to track a limited set of “Permitted Events” (like Web Push subscriptions) without associating them with a specific user identity.
- Cross-Subdomain Support: Synchronizes the opt-out state across subdomains (if configured).
Server Data NoticeData erasure occurs only locally within the browser’s storage. Disabling data tracking does not retroactively delete historical data that has already been sent to and stored on MoEngage servers.
Disable Data Tracking
Call the disableDataTracking() method when a user rejects tracking cookies or requests to opt out.
Moengage.disableDataTracking();
What happens when disabled?
- New custom events and user attributes are not tracked.
- PII (Email, Mobile Number, Name, etc.) is blocked from being sent to the server.
- The SDK logs an error if you attempt to call
disableDataTracking() when it is already disabled.
- If the SDK itself is disabled via
disableSdk(), calling disableDataTracking() will have no effect.
Enable Data Tracking
Call the enableDataTracking() method when a user provides consent to be tracked.
Moengage.enableDataTracking();
Re-identifying Users after Consent
After enabling data tracking, you must call identifyUser() to associate the current session and any prior anonymous events with a specific user profile.
Moengage.enableDataTracking().then(() = {
// Re-identify user to link anonymous events to the profile
Moengage.identifyUser("USER_UNIQUE_ID");
})
The Data Tracking Opt-out feature is currently supported on the following platforms and frameworks:
| Platform / Framework | Support Status |
|---|
| Native Web SDK | ✅ Supported |
| NPM Module | ✅ Supported |
| Google Tag Manager (GTM) | ✅ Supported |
| Shopify | ✅ Supported |
| Flutter | ✅ Supported |
| Segment / VTEX / AMP | ❌ Not Supported |
Data Collection Behavior
Permitted Events
When data tracking is disabled, the SDK tracks standard events anonymously to maintain core functionality. For a full list of these interactions, refer to the Standard Events documentation. All standard events are tracked except for custom events and user attributes, which are restricted as listed below.
Restricted Data (PII)
Restricted Attributes
- Personal Identifiers: First Name, Last Name, Full Name.
- Contact Info: Email ID, Mobile Number.
- Demographics: Gender, Birth Date.
- All custom user attributes.
- All custom events.
Frequently Asked Questions
Does the opt-out state persist after a user logs out?
Yes. The tracking preference is stored in the browser’s storage and persists across app sessions and user logouts to ensure user privacy choices are respected.
Will I still see page view counts for opted-out users?
Yes. Viewed Web Page is a permitted event. However, these views are recorded anonymously and are not linked to a specific user profile or historical data.
Can I use this alongside disableSdk()?
disableSdk() takes precedence. If the SDK is disabled, SDK does not perform any operations. disableDataTracking() allows the SDK to remain active for anonymous features while stopping personalized data collection.