<script>
function getUrlParameter(name) {
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(location.search);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
(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://yourmautic.com/mtc.js','mt');
var email = getUrlParameter('email');
if(email !== ''){
mt('send', 'pageview', {email:email, tags:'DOI'});
} else {
mt('send', 'pageview');
}
</script>
However sometimes the contact is not updated in Mautic after the contact visits the landing page. This seems to happen at random. It will work one day and the next it will not. It will tag some contacts but others it will not.
I am using a browser with clean cache and emails never used before on the Mautic instance. I’m also making sure the Mautic admin uses a different browser and is not open when testing.
Has anyone else seen similar behaviour when using this javascript on external landing pages?
Hi Joey,
That’s a a very quick reply and from the author himself! The tracking/tagging script is included in the external https://domain.com landing-page. Mautic is on a subdomain https://mautic.domain.com with the domain CORS whitelisted in the Mautic config.
I’m using the javascript on two domains landing pages each with their own Mautic. Both are showing this behaviour.
The contacts are sent to the subscription confirmation landing page via the double opt-in email. This is passing the contact email and name.
Very weird, when it ‘sometimes’ happens. You will need to find some kind of rule, so I can reproduce it.
If you want you can send me the page in private message, and I take a look!
Hi Joey,
It was a problem with other javascript on the site interferring with the Mautic tracking javascript. Now the tracking and tagging is working perfectly using the script on the landing page.