i need to trigger a tag with a custom event. For test, i have created a test tag with a simple javascript alert. And i have placed this code before the container between but it doesn’t work:
<script type="text/javascript">
var _mtm = _mtm || [];
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
_mtm.push({'event':'js_alert'});
</script>
note: The tag is triggered if i replace the trigger “custom event” for the predefined “pageview”.
I don’t know what i am doing wrong. Please, can you help me?
Thank you very much.
Thanks for your post, I wish I could see more post here about Matomo Tag Manager.
I am a bit confused, I am not sure about what you are trying to achieve.
Could you please tell me what you would like to get at the end?
I mean do you just want to get a JavaScript alert to fire when a page is viewed? I mean this is what I understood.
Just confirm this point and I will do my best to answer accordingly.
I just want to trigger the tag with a custom event. it seems that the _mtm var is not read by the container script. i don’t see anything relative to the _mtm var in the debug window.
Sure, no problem Cédric, do not hesitate to post within the French forum, I will answer in French on it. Do you have a custom event in mind you would like to use as a trigger? By default MTM is offering many.
en effet, je n’arrive pas à comprendre pourquoi cela ne marche pas non plus de mon côté, j’ai bien le datalayer avec l’evenement jsalert dans la console mais cela ne se déclenche pas.
Which triggers the event after 5s. I’ve tried to create a quick fix for this but it is not trivial to make this happen and need to spend a day or so checking how we can make this work.
Bonjour,
J’ai le même problème. Je n’arrive pas à déclencher un évènement même un simple alert().
On dirait qu’aucun de mes évènements personnalisé n’est pris en compte.
J’y ai passé la journée je sèche. Pourtant si teste le même code avec GTM ça fonctionne.
Je suis sûrement passé à côté de quelquechose.
Merci pour votre aide.
The initial post is 4 years old, and so the solution…
It should have been better to start a new post…
Did you publish your container?
Did you test it in debug mode? Are the trigger… triggered?
Is there any JavaScript error?
Note: Use of console.log() is better than alert()…