matomo-org / tag-manager

Free Open Source Matomo Tag Manager - A simple way to manage and maintain all of your (third-party) tags on your website.
https://matomo.org
GNU General Public License v3.0
176 stars 58 forks source link

Add tag firing section: "Only fire this tag if VARIABLE_NAME = XYZ" #892

Open Stan-vw opened 2 months ago

Stan-vw commented 2 months ago

Currently, firing logic for Tags is a combination of:

However, you cannot configure the tag to trigger:

This could be handy for managing logic like "only fire when consent is given", or "only fire for specific audiences". This logic is available in the trigger configuration, but this can result in having duplicate triggers with slight variable differences, rather than having a single generic trigger and adding the nuance to the specific tags that require it.

Related conversation: https://github.com/matomo-org/tag-manager/issues/761#issuecomment-2370160407

AltamashShaikh commented 2 months ago

@Stan-vw A DOM Ready trigger with below filter can solve the problem of firing a tag for a sepcific variable

Screenshot from 2024-09-25 09-22-51

Stan-vw commented 2 months ago

@AltamashShaikh yes, I believe that's what I described:

*I'll update the title, since the original title might be slightly inaccurate

SW-Vincent commented 2 months ago

As a reference, it sounds like the "Perimeters" feature of Tag Commander (TMS from commander act). image

The main point is to use and reuse some generic triggers for different context without having to create one trigger per context. This way we might have one consent change trigger and one consent status variable per analytics / ads tool rather than having an expodential number of triggers (this is nothing but an example of many uses).

Not to confuse with group of triggers that is an existing GTM feature (and the subject of an existing github ticket), which is more of a "wait for all triggers" trigger (ex : event + consent change, again just an example of many uses).

Stan-vw commented 1 month ago

Rough indication of suggested change: image

snake14 commented 1 month ago

As far as implementation, we might be able to use the same meetsConditions function that triggers use in the tag's _doFire method.