Skip to main content

Troubleshooting

Adding a Custom Trigger in Google Tag Manager

This is a troubleshooting method for a range of issues including concurrency or the behaviour of your cookie management platform (CMP) resulting in incorrect or inconsistent script fires. Setting up a custom trigger allow you to pick a specific event to use as a trigger for the script, letting you better control the behaviour.

This can all be done in Google Tag Manager, but identifying the issue and what event to use as a custom trigger can be tricky so we recommend having a developer on hand to do this. This set up should take around 30 mins to an hour.

Identifying the Event to use as a Trigger

To find the trigger from your CMP go into GTM into Preview Mode and click accept on your cookie banner. Look at the events coming into GTM. Clear cookies and repeat with reject on your cookie banner. Copy this event name.

For some CMPs this will be the key event needed, for others it may be less straightforward. What is needed is an event sent from your CMP when the user interacts.

Set up in GTM

  1. Set up a consent status variable under Variables > New > Data Layer Variable
  • Use the event that found in Preview mode.
  • Name this Consent Status or similar.
  1. Set up a custom trigger for cookies denied.
  • Set it to fire on Some Custom Events.
  • The condition for triggering is Consent Status contains denied or whatever value you found when cookies are denied in Preview mode.
  • Add the cookieless Dreamdata script. This is the second script when copying both from Data Platform > Sources > Javascript v2.0, it contains the name 'dreamdata-cl'.
  1. Set up a custom trigger for cookies accepted.
  • Set it to fire on Some Custom Events.
  • The condition for triggering is Consent Status contains accepted or whatever value you found when cookies are accepted in Preview mode.
  • Add the normal Dreamdata script. This is the first script when copying both from Data Platform > Sources > Javascript v2.0.
  1. Set up a custom trigger of type Timer.
  • Set the interval to 5000 miliseconds or similar (5 seconds—enough time for a normal user to see the banner).
  • Set the Limit: to 1. Enable when: Page Path matches RegEx .*. for any.
  • This trigger fires on: Some Timers.
  • For the Condition: add Consent Status is null (meaning no interaction event has happened yet).

How to Test

Our testing guide can be found here. The key thing to look for is that only the normal script is fired when cookies are accepted and cookieless fired in all other scenarios.