Skip to main content

Troubleshooting

Adding a Custom Trigger in Google Tag Manager

This is a troubleshooting method for instances where concurrency issues from your cookie management platform (CMP) are causing inconsistent script fires. If the root of the issue is your CMP not always loading before GTM then one method of troubleshooting is setting up a custom trigger that takes the state of your CMP and makes sure it is loaded before the dreamdata script.

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, or to help. This set up should take around 30 mins to an hour.

How to Diagnose the Problem:

The key giveaway that concurrency is a problem is when cookies are accepted but the script fires inconsistently. If sometimes the full script fires, sometimes the cookieless fires, and sometimes both, this is a key indicator that there is a loading issue.

If this behavior is present on your site, navigate with cookies accepted until you get both events firing. Then in the Network tab in Chrome developer tools look at the Initiator tab and check what is causing the script to fire. If you see a cookieless event fired by Google Tag Manager and a normal script fired by your cookie banner, then this is likely your problem.

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.