Updating mautic contact with details from WPForms form

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;


<p>Thanks for contacting us! We will be in touch with you shortly.</p>

    //mt('send', 'pageview');
    mt('send', 'pageview', {email: '{field_id="1"}', firstname: '{field_id="0"}' tags: 'Contact Form'} );	

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.

If anybody else comes across this and wants to do something similar the problem was with the spacing (besides the missing comma above). It seems WPForms puts <p></p> tags in the way when there are line breaks which messed up the script. It’s working now.