Programmatic API
Last updated
Last updated
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 function. You can find more examples and documentation on the function in the .
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.
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 function to check if consent is required or not for the current visitor on the page.
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 function to check if consent is required or not for the current visitor on the page.