Aaryn
Aaryn

Reputation: 1643

Google Tag Manager - Only allowing tags on defined pages

I have a couple of tags that inject some HTMl and JS on a page. We only want these tags to be delivered on certain pages as a whitelist while the feature is rolled out, and also have the ability to allow non-technical staff to add new URLs to this whitelist without the need for code changes across three different sites.

I had a look a triggers and adding Page URL criteria to one. Which works for one URL, but these criteria form an AND relationship, so adding more just kills the trigger.

Fire this trigger when an Event occurs and all of these conditions are true

I have also read about the gtm.whitelist and gtm.blacklist dataLayer params.

dataLayer = [{
  ...
  'gtm.whitelist': ['<ID>', '<ID>', ...]
  'gtm.blacklist': ['<ID>', '<ID>', '<ID>', ...]
}];

However this the requirement for non-technical users to add locations, as well as creates quite a bit of logic for three seperate dev teams to implement a method of altering the dataLayer on a per page basis.

Can anyone think of a solution to this? At this stage, the only way I see of doing it is adding one trigger per page/path that we want to include these tags. Which will be fine initially as we roll out to a couple of site sections. But that trigger creation and length of triggers on the tag will become quite long eventually.

Upvotes: 0

Views: 2049

Answers (1)

Matus
Matus

Reputation: 1418

You can use lookup table for your trigger (google support pages for variable types) .

That way you will only need one trigger for example, if you can create "White-list trigger" :

enter image description here

then you can setup your "White-list lookup" variable as either RegEx table or standard Lookup table, e.g.:

enter image description here

With RegEx you will have more flexibility to whitelist site sections however if you have non-technical people adding URLs to the whitelist you might choose to use standard Lookup table.

A useful link: Article about RegEx table.

Upvotes: 1

Related Questions