Pass Consent Data Using the Elevar Consent API
Learn how to pass customer consent values to the Elevar Consent API
Overview
Use this guide to learn how to pass consent values to the Elevar Consent API when using a custom Consent Management Platform (CMP) or consent solution.
If you are collecting customer consent outside of Elevar's supported integrations, you can pass those consent values directly to Elevar through the window.ElevarConsent object. This allows Elevar to respect your customer's consent choices while ensuring consent updates are applied correctly across supported destinations.
This guide explains how to initialize the Elevar Consent API, configure default consent states, and update consent values after a customer makes their consent selections.
How the Elevar Consent API Works
When implementing the Elevar Consent API, your custom consent solution is responsible for collecting the customer's consent preferences and passing those values to Elevar. Before the Elevar script loads, you must initialize the window.ElevarConsent object as an empty array. Doing so disables Elevar's automatic consent detection logic and allows your implementation to manage consent directly. Once consent has been determined, or whenever a customer's consent preferences change, you can push the updated consent values into the window.ElevarConsent object.
Supported Consent Categories:
The Elevar Consent API supports the following consent categories:
- ad_storage
- ad_user_data
- ad_personalization
- analytics_storage
- functionality_storage
- personalization_storage
- security_storage
Each consent category supports the following properties:
- default: Sets the initial consent state.
- update: Updates the consent state after the customer has made a consent selection.
Initialize the Elevar Consent Object:
NOTE:The window.ElevarConsent object must be initialized before the Elevar script loads. If this object is not initialized first, Elevar will execute its automatic consent logic instead of waiting for your custom consent implementation.
Initialize the consent object by setting it to an empty array:
window.ElevarConsent = [];Once initialized, your consent management solution can push consent updates into this array whenever consent is known or changes.
Set Default Consent Values:
If your implementation requires all consent categories to default to denied, push the following object after initializing the consent array.
ElevarConsent.push({
ad_storage: { default: false },
ad_user_data: { default: false },
ad_personalization: { default: false },
analytics_storage: { default: false },
functionality_storage: { default: false },
personalization_storage: { default: false },
security_storage: { default: true }
});In this example:
- Advertising consent is denied by default.
- Analytics consent is denied by default
- Functional and personalization consent are denied by default.
- Security storage remains enabled by default, as it is generally required for essential site functionality.
Set Default Granted Consent:
If your implementation begins with consent already granted, push the following object:
ElevarConsent.push({
ad_storage: { update: true },
ad_user_data: { update: true },
ad_personalization: { update: true },
analytics_storage: { update: true },
functionality_storage: { update: true },
personalization_storage: { update: true },
security_storage: { update: true }
});This example updates every supported consent category to a granted state.
Update Previously Denied Consent:
When a customer initially denies consent but later accepts tracking, push an updated consent object that includes both the original default value and the updated consent state. This example indicates that consent was originally denied for most storage types but has now been updated to granted after the customer changed their consent preferences.
window.ElevarConsent.push({
ad_storage: { default: false, update: true },
ad_user_data: { default: false, update: true },
ad_personalization: { default: false, update: true },
analytics_storage: { default: false, update: true },
functionality_storage: { default: false, update: true },
personalization_storage: { default: false, update: true },
security_storage: { default: true, update: true }
});
