_mtm.push for Event Tracking (versus _paq.push)

How to call EVENT Tracking for (Category, Action, Label, Name, Value) Using custom HTML : _mtm.push method
var _mtm = _mtm || ; and _mtm.push({ });

simillar to below method which working but not supporting properly in matomo

_paq.push([‘trackEvent’, category, action, name, value, {dimension1: ‘DimensionValue’}]);

        _mtm.push({
            'event': 'customEvent',
            'customCategory': category,
            'customAction': action,
            'customLabel': label,
            'customValue': value
        });

This below one is triggering and showing on debugger, when we run in console

$(’.columns.medium-4.storyItem’).click(function(){
var label =$(this).find(’.storyTitle’).text();
if (label != “”){
alert(label);
window._paq = window._paq || [];
window._paq.push([‘trackEvent’, ‘In page555’, ‘click555’, label]);
}
})


This below one is not triggering and showing on debugger

$(’.columns.medium-4.storyItem’).click(function(){
var label =$(this).find(’.storyTitle’).text();
if (label != “”){
alert(label);
window._mtm = window._mtm || [];
window._mtm.push({
‘event’: ‘customEvent’,
‘customCategory’: ‘In paGe’,
‘customAction’: ‘ClicK’,
‘customLabel’: label
});
}
})

URL : https://www.grunenthalhealth.de/de-de/medizinisches-fachpersonal/neuigkeiten-und-artikel/

In my example, you have to have previously defined:

  • customEvent trigger
  • customCategory variable
  • customAction variable
  • customLabel variable
  • And a tag triggered on customEvent trigger…

$(‘.columns.medium-4.storyItem’).click(function(){
var label =$(this).find(‘.storyTitle’).text();
var category = ‘InpaGeee’;
var action = ‘InpaGeee’;
var value = ‘tttEST’;

if (label != ""){
   alert(label);
   window._mtm = window._mtm || [];
   window._mtm.push({
        'event': 'customEvent',
        'customCategory': category,
        'customAction': action,
        'customLabel': label,
        'customValue': value
    });
}

})

still not working

→ In the Matomo Tag Manager !

Another way of asking this question: “When adding an event to the request “stack” for Matomo using the _paq.push() method, will that information be transmitted by the Tag Manager at all?”


When the above two options are enabled in the Tag Manager it allows the use of all the normal tracker methods using the _paq.push method. The Tag Manager configures a default tracker object configured using the settings in the Matomo Configuration Variable. The _mtm.push method is not a direct replacement of _paq.push, _mtm.push simply pushes data to the Datalayer of the Tag Manager. You would still need to configure a Trigger to send any tracking requests once the data was pushed to the Datalayer. Using the _paq.push method for a tracker method would directly send a tracking request in this case.

Here is some example syntax, in case you are using the browser console to experiment with some Javascript for _paq.push().

_paq.push([ function() {console.log(this.trackPageView());}]);