User Consent Updated
An event that fires when the shopper updates consent.
Description
The onUserConsentUpdated listener fires when the shopper updates consent in the app.
The callback receives data. Each consent statement is a key, and the checkbox state is the boolean value. data.phone is the phone number entered on the same form, when the shopper provided one.
Statement keys are the copy shown on the consent form. They are not a fixed set.
This event does not update Superfans.variables. Read the answers from data.
Function Signature
Superfans.listeners.onUserConsentUpdated(function (data) {
const acceptedTerms = data["I have read and accept the Terms of Service and Privacy Policy."];
const phone = data.phone;
});| Parameter | Type | Required | Description |
|---|---|---|---|
| data | Object | Yes | Consent answers. Statement text is the key and the checkbox state is the boolean value. phone is a string when the shopper entered one. |
Example Usage
Superfans.listeners.onUserConsentUpdated(function (data) {
const acceptedTerms = data["I have read and accept the Terms of Service and Privacy Policy."];
const wantsOffers = data["I would like to receive offers and updates by email and SMS."];
const phone = data.phone;
if (acceptedTerms) {
console.log("Terms accepted", phone || "");
}
});Best Practices
- Read the payload from the callback. This event does not write into
Superfans.variables. - Match statement keys to the exact copy shown on the consent form.
- Treat
phoneas optional. It is present only when the shopper entered a number. - Use the event to sync marketing consent, or to gate a feature that depends on acceptance.
Caveats
- The event fires when consent changes, not on page load.
- There is no replay. A block that subscribes after the shopper submits consent does not receive the last answers.
- Keys are not stable identifiers. A copy change on the form changes the key.
phoneis a string on the same object as the boolean answers. Do not assume every value is a boolean.
Updated about 2 hours ago
Did this page help you?