Your Custom HTML should be only triggered if there is eg. a productdetail page event.
To do this you must send a data layer push only on any product detail page.
This information can be provided via a static data layer which exists before Tag Manager is loaded.
1. // Static Data Layer //
2. _mtm.push({
'event': 'productDetailView',
});
3. // Matomo Tag Manager Script //
The Custom HTML is only triggered if the event is pushed to the data layer.
Try it out.
Could be that there are some timing issues.
But even then you could set up a tag which pushes the ‘event’: ‘productDetailView’, only on pages with a specific URL-path and with some delay…
Many many options.
But try to control it via the back-end if possible.
Many thanks @Trackingninja for your suggestions.
I started with an event 'productDetailView" in the data layer. The custom HTML tag was only fired at this event, but unfortunately too late (after Matomo Analytics Tag with ‘trackPageView’). Same thing with a trigger for a specific url path.
Advanced setting for tags only seem to work within the same trigger.