Programmatic API
If you need more control over when and how tags are loaded, the Didomi SDK exposes a function to get an observable on the consent status for a given vendor. This allows you to listen to changes to the consent status and react to them to decide when to enable a vendor.
Here are a few use cases and how to implement them with the getObservableOnUserConsentStatusForVendor function. You can find more examples and documentation on the function in the Reference.
Enable a vendor when the user has allowed it
With this structure, your function gets called exactly once and only when the user has given consent to the vendor specifically. It could be immediately if the user has already given consent or later on after the user gives consent.
If your tag is configured to only collect consent for visitors from the EU, you can enable all your tags for other visitors without waiting for the consent. Use the isConsentRequired() function to check if consent is required or not for the current visitor on the page.
Get notified when the consent status for a vendor changes
With this structure, your function gets called every single time the consent status for the vendor changes. If the user has not given consent information yet, your function is called immediately with undefined
as the consent status. If the consent status of the user changes multiple times on the page, the function will be called multiple times.
If your tag is configured to only collect consent for visitors from the EU, you can enable all your tags for other visitors without waiting for the consent. Use the isConsentRequired() function to check if consent is required or not for the current visitor on the page.
Last updated