How to Track AJAX Forms
Overview
If you are working with AJAX forms, follow these steps to track conversions when an AJAX form is submitted.
1. Add SEAL’s Tracking Pixel
Add the SealMetrics tracking pixel to all pages of your website.
2. Trigger Conversion After AJAX Form Submission
When the AJAX form is successfully submitted, fire the following tracking code:
<script>
/* SealMetrics Tracker Code */
var oSm = window.oSm || {};
oSm.account = 'XXXXXXXXXXXXXXXXXXXXX';
oSm.decore = 1;
oSm.event = 'conversion';
oSm.label = 'form-lead';
!function(e){
var t="//app.sealmetrics.com/tag/tracker";
window.oSm=oSm,
window.smTrackerLoaded
? sm.tracker.track(e.event)
: Promise.all([
new Promise(function(e){
var n=document.createElement("script");
n.src=t,
n.async=!0,
n.onload=function(){e(t)},
document.getElementsByTagName("head")[0].appendChild(n)
})
]).then(function(){
sm.tracker.track(e.event)
})
}(oSm);
/* End SealMetrics Tracker Code */
</script>
Notes
- Fire this snippet only after the AJAX form is successfully submitted.
- This script will register a conversion event with the label
form-lead.