3

I'm trying to achieve the following:

  • One GTM container for multiple websites/domains (within the same platform)
  • Only fire tags that are active for the current website (by checking configured analytics / criteo / adwords / other vendor account id in data layer)
  • Configure triggers like 'booking page reached' and 'booking created' once (by custom event and using data layer)

My problem is combining the condition 'active tag' (checking for account id) with a 'booking created' event without duplicating logic. Because every trigger is an OR condition, not an AND condition.

Currently, this results in creating exceptions that are very specific, and contain most of the triggers like 'Booking created', specific for a tag (Analytics / Criteo / Adwords). Resulting in having to still make very specific (duplicate) triggers, instead of re-using them. Main issue is exceptions have to match the event type of the trigger. And triggers cannot be combined nor extended.

My tags / triggers configuration looks like this now:

current GTM configuration with specific exceptions

My questions:

  • Is there a way to combine multiple triggers (AND instead of OR)
  • Can I create an exception for tag that is not depended on the same event as the original trigger?
  • Am I looking for a solution in the wrong direction? How do I prevent triggering a tag that is disabled (by dataLayer), without duplicating 'custom events' logic for every different tag / vendor.
Fabien Benoit-Koch
  • 2,784
  • 2
  • 21
  • 33
Erik Baan
  • 436
  • 6
  • 12
  • 1
    "Main issue is exceptions have to match the event type of the trigger" - the common workaround is to use a trigger of the custom event trigger, check "use regex" and enter ".*" (i.e. "all events). Then add your conditions. – Eike Pierstorff Dec 27 '18 at 17:45
  • @EikePierstorff Thanks! Thats a nice workaround. Now it only requires one 'exception trigger' per event type (Page View / Custom Event in my case)? Or will a custom event with regex .* even match a 'default' Page View event? (I will test this myself) – Erik Baan Dec 27 '18 at 18:47
  • A Custom Event with .* regex will also match a default Page View event. So now it only requires one exception trigger. Great! This will make the configuration much easier. If you post this as answer, I can accept it. – Erik Baan Dec 27 '18 at 18:53

2 Answers2

4

There is a more powerful and easiest way to combine triggers in multiple AND and OR.

First of all: if you need to combine triggers with just OR condition, you can simply add a list of triggers when you are configuring a tag. I am no talking about exceptions, just triggers. You can click on the (+) symbol and every trigger you add is managed with OR condition.

But, if you need, for instance, to add two triggers in AND? There is a very simple way that does not imply the regex.

Is the trigger group feature. Here are the steps.

  1. Create all the triggers you need to compose (in this phase you don't need to combine them, just one trigger at a time)
  2. Then create a new trigger, but in this case, choose the last type in the list, that is "trigger group". Et voilà... you can combine in the group any of the existing triggers and define if you wnat combine them with AND or OR!!!! :)

Finally, go to your tag and use the GROUP instead of the single trigger.

That's all

Omar Venturi
  • 91
  • 1
  • 7
  • I don't think you can use OR with groups, it's always in AND mode. Or am I missing something? – Selfish Sep 18 '19 at 08:23
  • Unfortunately, you're right. Trigger Group currently works only with an AND relationship. – Koby Jan 09 '20 at 11:37
  • And I've just discovered a big problem with Trigger Groups: they're only triggered once per page, so if you need them more than once (p.e. you have a Single Page Application) you're out of luck https://www.simoahava.com/analytics/trigger-groups-google-tag-manager/#trigger-groups-will-fire-just-once – Sergi Oct 30 '20 at 13:20
3

If your main problem is that "exceptions have to match the event type of the trigger", the common workaround is to use a trigger of the type "custom event", check "use regex" and enter ".*" (without the quotes), which matches all events, including the built-in pageview (gtm.js), DOM ready (gtm.dom) and Window loaded (gtm.load). Then add conditions as needed.

GTM trigger custom events

Eike Pierstorff
  • 31,996
  • 4
  • 43
  • 62
  • Is there any reason not to create all triggers as custom events with Event name set to `.*` paired with a "This trigger fires on" setting? I would think that would allow one to use any trigger as an exception if needed. My only concern here would be performance perhaps. Unless the "This trigger fires on" is enough to scope the trigger down enough. – King Holly Dec 02 '20 at 07:25