I’m using the javascript tag method to update contacts with a tag as provided here Instant Double Opt-in without cronjobs (3 examples) – Joey Keller.
<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?