Your software
My Mautic version is: v5.0.2
My PHP version is: 8.0.24
My Database type and version is: MySQL 10.4.34-MariaDB
Your problem
My problem is:
There are limited events avaliable to be captured in Mautic. So, I am using Google Tag Manager for various types of events such as clicks on all the elements on a web page. Once the click event is performed, by using the mautic tracking pixel code, the information from GTM to Mautic is sent. But the event type is shown as Page Hit rather than Click in Mautic.
Steps I have tried to fix the problem:
I created 2 separate tags in GTM: one for Page view and the other for Click.
Page View Tag
<script>
(function(w,d,t,u,n,a,m){w['MauticTrackingObject']=n;
w[n]=w[n]||function(){(w[n].q=w[n].q||[]).push(arguments)},a=d.createElement(t),
m=d.getElementsByTagName(t)[0];a.async=1;a.src=u;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://mac.eventassay.com/mtc.js','mt');
mt('send', 'pageview');
</script>
Click Tag
<script>
(function(w,d,t,u,n,a,m){w['MauticTrackingObject']=n;
w[n]=w[n]||function(){(w[n].q=w[n].q||[]).push(arguments)},a=d.createElement(t),
m=d.getElementsByTagName(t)[0];a.async=1;a.src=u;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://mac.eventassay.com/mtc.js','mt');
// Add event listener for click tracking
document.addEventListener('click', function(event) {
mt('send', 'event', {
eventCategory: 'Click',
eventAction: 'click',
eventLabel: event.target.tagName + ' - ' + event.target.innerText
});
});
</script>