I have mautic tracking anonymous users on my wordpress website using the wordpress plugin.
I’m attempting to get these anonymous contacts updated with email addresses when a user submits a WPForms form on the website but aren’t having much luck.
What I’ve tried;
Adding
<p>Thanks for contacting us! We will be in touch with you shortly.</p>
<p> </p>
<p><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','http://m.mydomain.com/mtc.js','mt');
//mt('send', 'pageview');
mt('send', 'pageview', {email: '{field_id="1"}', firstname: '{field_id="0"}' tags: 'Contact Form'} );
</script></p>
to the confirmation message displayed by WPForms.
If I view the source code of the page after the form has been submitted the email and firstname of the mt('send', 'pageview', {email: '{field_id="1"}', firstname: '{field_id="0"}' tags: 'Contact Form'} );
function contains the correct details but mautic doesn’t get updated.
I think the script probably isn’t running on the page? I’m not great with javascript, how do I get the script to execute? Or is it a different problem I’m running into?
I know I can (and maybe should) use a mautic form for this but I have to update a few and the WPForms form does it’s job at the moment.