Opt-out
When opt-out is enabled, the SDK stops sending all events.
Configuration at Initialization
const config = {
optOutTracking: true
};
const hackleClient = Hackle.createInstance("YOUR_BROWSER_SDK_KEY", config);Runtime Opt-out Control
hackleClient.setOptOutTracking(true);
hackleClient.setOptOutTracking(false);
const isOptOut = hackleClient.isOptOutTracking();Persistence Management
The value resets to the value configured in Config on page refresh or revisit.
To maintain state across page refreshes, you must implement your own save and restore logic.
function saveOptOutState(optOut) {
localStorage.setItem("hackle_opt_out", JSON.stringify(optOut));
hackleClient.setOptOutTracking(optOut);
}
function getOptOutConfig() {
const optOut = JSON.parse(localStorage.getItem("hackle_opt_out") || "false");
return {
optOutTracking: optOut
};
}
const config = getOptOutConfig();
const hackleClient = Hackle.createInstance("YOUR_BROWSER_SDK_KEY", config);Last updated