does anyone here have any idea how to set up Site Tracking by passing a contact’s email address into Javascript Code?
I am on WordPress using the visual builder Elementor’s native contact form.
Here’s the contact form: https://www.bestseo.sg/free-report/ (Bottom of the page)
I have already inserted ActiveCampaign’s site tracking code sitewide.
However, it does not seem to start site tracking even after the form submission.
According to ActiveCampaign’s documentation(https://help.activecampaign.com/hc/en-us/articles/221542267-An-overview-of-Site-Tracking#how-to-pass-a-contact-s-email-address-into-javascript-code), I believe I have to add this line of code:
vgo('setEmail', 'Email_Address_Goes_Here');
above
vgo('process');
But I have no idea what to replace ‘Email_Address_Goes_Here’ with, in order to call the actual contact’s email after form submission.
Any help would be much appreciated!
Thank you.
2
Answers
So the plugin used to insert these JavaScript codes is https://wordpress.org/plugins/header-and-footer-scripts/ – I’d suggest to maybe just keep using that, and keep the scripts in the footer, so that this does not require too much modication.
Inside your template, you have to output the email addresse somewhere, where the JS can read it from – via a custom data attribute added to the body element for example.
The header.php of your theme should contain something similar to
Modify that, to add a custom data attribute to store the email address entered in the from:
If the POST parameter by that name is set, then it will be output as content of this attribute, otherwise it’ll simply stay empty.
Then modify the JavaScript code you insert via the plugin like this,
This assumes that jQuery has already been loaded at this point, but I think that should most likely be the case.
If the attribute contained an email address, then this will execute the
vgo
tracker function, if the attribute value is empty, then it will simply skip this call.This is not the most sophisticated approach, but it should do.
(Only if you had other forms on the site as well, that use a form field of that exact same name, you might be tracking more than intended. In that case, you’d need to find some additional criterion, to be able to differentiate between these different forms.)
A person at the AC support gave me thsi code :
I hope it’ll help you.
I use FluentForms, so i just went on the form specific Custom JS/CSS to apply it (so i had no problems of proper targeting…)