Custom events
If you have your own custom events that you use as triggers for tags and also want to add an additional condition on the consent status of the user, you need to make sure that your custom events only fire after the Didomi event that you are using (so that the Didomi variables have already been populated). You have two options to do so.
Option 1: Wrap your custom events
In your JavaScript code that is pushing your custom events onto the data layer, wrap all your custom events to only fire them after the Didomi SDK has initialized and the didomi-ready
event has been sent:
You can use as many didomiOnReady
functions and put them anywhere in your code. Custom events that are not used as triggers for a tag that you want to condition on consent do not need to be wrapped.
If you do not wait until the Didomi SDK is ready before firing your custom events, the order of the events will end up being random and you have no guarantee that the consent is correctly enforced for the tags using custom events triggers.
Option 2: Condition your custom events
The second option is to only fire your custom events when you have consent. In that case, you do not need to add a consent condition in GTM and the mere fact that the event gets fired implies that consent was given
It is not ideal because is pushes the consent condition into your JavaScript code but can be useful sometimes.
Last updated