Documentation Index
Fetch the complete documentation index at: https://moengage-getz-tagging-workspace-status.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Empower User Privacy with MoEngage Web SDK
The MoEngage Web SDK empowers you to offer your users explicit control over their data tracking. This is crucial for complying with privacy regulations such as GDPR and CCPA, ensuring that you collect data only from users who have given their explicit consent. With this feature, you can dynamically disable and enable the SDK, providing a flexible approach to managing user privacy preferences.Understand SDK Opt-Out Functionality
When the MoEngage Web SDK is disabled (either during initialization or by a subsequent API call), its data tracking and communication capabilities are paused. This means the SDK will cease to collect or transmit user data and will not perform most of its usual functions. When the Web SDK is disabled:- No Data Transmission: The SDK will not track or send any user attributes, event data, or device information to MoEngage servers.
- Queue Clearance: Any data pending in the SDK’s batch queue will be cleared and will not be sent.
- Feature Impact: Most SDK features that depend on active data tracking (like analytics, personalization, and triggered campaigns) will become unavailable.
- Web Push: Users will no longer receive push notifications.
How to Disable SDK?
Disable SDK at Initialization (Preventing Initial Tracking)
To prevent any data tracking from the moment your website loads, you can initialize the SDK in a disabled state. This is achieved by passing thedisableSdk: true parameter in the SDK’s initialization configuration.
disableSdk: true:
- It will not make any initial network calls for device registration (for example,
device/add) or to fetch configurations (for example,websdksettings,sdkconfig). - No default events that are typically tracked on page load will be recorded or sent.
- The SDK will remain dormant until it is explicitly enabled via an API call.
NoteIf you initialize the SDK with
disableSdk: true and later enable it using Moengage.enableSdk(), remember to remove the disableSdk: true parameter from your SDK initialization code for subsequent page loads. Otherwise, the SDK will revert to a disabled state on the user’s next visit.Disable SDK Dynamically (After Initialization)
If the SDK is already initialized and operational, you can dynamically disable all its data tracking and other functions by calling thedisableSdk() method. This is particularly useful for scenarios where a user revokes their consent for data tracking after initially granting it.
disableSdk():
- All data currently in the batch queue is discarded and not sent to MoEngage.
- Any subsequent attempts by your application or by the SDK internally to track events or user attributes will be ignored.
- The current user’s session data and locally cached attributes are cleared.
- Core identifiers are retained (though inactive) to ensure a smoother experience if the SDK is re-enabled and to avoid unnecessary re-registrations.
- If cross-domain data sharing is enabled, data tracking will also cease on any linked subdomains.
Enable SDK to Start Data Tracking
To resume data tracking and all other SDK functionalities after the SDK has been disabled, call theenableSdk() method.
enableSdk() is invoked:
- If the SDK was initially disabled via the
disableSdk: trueparameter, calling this method will trigger the complete SDK initialization sequence (including device registration and fetching remote configurations). - If it was disabled dynamically, it resumes operations from its previous state. Event and attribute tracking will function again.
- Push notifications will be available to be shown to the users.
Check the SDK’s Current Status
To determine whether the Web SDK is currently enabled or disabled, you can use theisSdkEnabled() method.
true: The SDK is enabled and operational.false: The SDK is disabled.