C15T Logo

Setting consent

Methods for managing a user's consent.

tocOn this page

setSelectedConsent()

This method sets a user's consent choice but doesn't save it.

setSelectedConsent('marketing', true) 

saveConsents()

This method should be called after the user saves their consent preferences, e.g., via an 'Accept all' button or a dialog save. This function handles logic such as calling the backend and the onConsentSet callback.

saveConsents('all') // User has accepted to all
saveConsents('custom') // Uses the consents set by setSelectedConsent()
saveConsents('necessary') // User rejects all 

setConsent()

Useful for buttons like "Enable Marketing Consent", this will save the user's new consent by calling saveConsents().

setConsent('marketing', true)