I have a Google Tag Manager tag configured to fire on all page views. However, on some pages, I may need to disable the tag based on internal data. To me, this sounds like a job for the dataLayer.
My initial thought was to create a dataLayer variable called "disableGTMTag" and give it a value to validate against. Then GTM could evaluate that value and take appropriate action.
So, in the dataLayer I created a disableGTMTag variable and hard-coded it to always have a value of "google" (for testing purposes). Running the page in GTM debug mode, I can confirm that the disableGTMTag variable is present in the dataLayer with the value "google".
To set up the tag, I updated the tag's trigger to fire only when disableGTMTag does not contain "google". But the tag still fired. I then tried setting the trigger to fire on All Pages but added an exception when disableGTMTag contains "google". The tag still fired.
My understanding is that a trigger exception must be the same type as the firing trigger. But I went ahead and created a secondary exception for a custom event that matches the regex ".*" that looked at the disableGTMTag value. Still, the tag fired when the page loaded.
This seems like a straightforward thing: always run this tag, unless this dataLayer variable tells you not to. But it's just not working for me.
Is there a different approach to restrict page view firing? How do I prevent page view-based tags from firing using a dataLayer variable?