Submit Button Tracking
Manual Form Tracking - Submit Button
With Submit button tracking, you can use JavaScript on the page your form submits, to scrape the variables submitted at the point of submission.
This tag should only be placed on the page where you want to track a specific form. This works by targeting the Submit button of the specified form and on click will fire the track conversion to Ruler Analytics.
Please see below an example of an on submit button script you can add to your website. Please note you can capture any additional variables from the form such as (Company,Post code and so on) You would just need to add an extra comma seperated line for each variable.
Please note you can update the below script to grab the values using the Input ID, Class or Name. The example JS would just need to be updated appropriately.
Please ensure you populate the below script using the relevant input and submit ID values from the form you wish to track. You can find the fields input IDs by inspecting element on the form in question on your site.
<script type="text/javascript">
window.addEventListener('load',function(){
function RulerManualSubmitClickTracking() {
try {
if (!RulerAnalyticsVisitorId)
throw "Ruler Analytics is not set on the page";
var emailInput = document.getElementsId("POPULATEWITHFIELDINPUTIDHERE");
if (emailInput === undefined) {
return;
} else {
var RAConv = {
Name: document.getElementById("POPULATEWITHFIELDINPUTIDHERE").value,
Email: emailInput.value,
Phone: document.getElementById("POPULATEWITHFIELDINPUTIDHERE").value
};
RulerAnalytics.trackConversionAsync(RAConv,"","",500);
}
} catch (error) {
console.error(error);
}
}
// Event Listener for clicks
document.getElementsById("POPULATEWITHSUBMTIDHERE").addEventListener('click', RulerManualSubmitClickTracking);
document.getElementsById("POPULATEWITHSUBMTIDHERE").addEventListener('touchend', RulerManualSubmitClickTracking);
});
</script>
NOTE
If you have validation on the form you are wanting to Manual Track via the Submit Button Tracking, then it is important that you add the above code inside the acceptance part of your validation. However, if your validation is placed outside of the page where the form is hosted, then you might need to pass over the form values or place a boolean on the page that can be used as part of an if statement to run the Submit Button Tracking only on acceptance.
If you require any assistance or have any questions please contact our Support Team
Updated 2 days ago