Repush dataLayer events that occurred before consent loaded.
dataLayer events allow you to fire your tags at the right moment with the correct data. The timing becomes more complex when consent becomes involved. If your dataLayer push arrives before the consent management platform and Google Consent Mode (Basic) have initialised - functionality is needed to delay firing the respective tag.
Trigger groups are the feature available in GTM to handle this, but they are unwieldy and can lead to very messy setups. Some of the data associated with the event may also not be available when the trigger group fires.
backTrack is a template attempting to solve this issue and make handling event-timing a lot easier and more convenient.
- Install the template from the community gallery
- Create a tag using the template.
- Set the tag to fire once per page.
- Add a trigger to fire the tag on the first event with consent.
Example:
- [Optional] Configure the REGEX for which events you want to re-push. By default GTM events and the most common consent events are excluded from being re-pushed. This is very important to prevent the consent state from being altered. To be explicit, change the REGEX to match the specific events you want to re-push.
- [Optional] Configure the prevent recursive merge feature by changing the setting to ‘On’ and adding any objects that should be cleared between events (for example ecommerce).
Example:
Google Consent Mode (Advanced) has its own functionality to automatically fire events again after consent is granted (via the update command). backTrack will function for all tags as it is repushing events. To prevent duplicate events being sent, a blocking trigger needs to be added to all Google Tags when Consent Mode (Advanced only) is being used. The blocking trigger should fire on all events with pushType 'Artificial’.
After the tag has finished re-pushing all events, it will set a dataLayer variable backTrack_fired
with the boolean value true
to indicate that the tag has already fired.
The template has in-built functionality to prevent multiple firings, as this could cause infinite loops. It is still worth explicity setting the tag to fire once per page.
After the tag has finished re-pushing all events, it will set a dataLayer variable backTrack_fired
with the boolean value true
to indicate that the tag has already fired.
The aim of this template is not to track events that occurred before the user provided consent, rather to make handling the timing easier. A consent decision should be enforced by the banner before the user interacts with the page. If you have a single page application ensure that the entire page is reloaded when consent is changed - as this is needed to unload analytics/marketing libraries.