We recently launched a new product trial that captures lead information using a Marketo form and then redirects to the product for activation. We want to be able to track conversions in GA, LinkedIn, etc, so I need to decorate the form to capture the submission event.
Below is the code that we're using on our test page. Right now, it doesn't appear to work -- it just hangs on submission in perpetuity and no events are sent. Are we doing something wrong? My developer thinks it's something with GTM?
<script src="//app-ab43.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_1040"></form>
<script>
MktoForms2.loadForm("//app-ab43.marketo.com", "290-OJT-747", 1040, function(form) {
form.addHiddenFields({ previousURI: document.location.href })
form.onSuccess((values) => {
window.ga('send', {
hitType: 'event',
eventCategory: 'marketo',
eventAction: 'form-fill',
eventLabel: 'trialform',
hitCallback: function(values) {
document.location.href = `https://monitor.onclusive.com/wait_invite?email=${encodeURIComponent(values.Email)}`;
}
});
return false;
});
});
</script>
... View more