AnsweredAssumed Answered

GA Event for Marketo Form Submission

Question asked by Anuja Jadhav on Apr 5, 2019
Latest reply on Apr 8, 2019 by Sanford Whiteman

Hello All,

 

I am aware that this topic is covered in a post but I am recreating a new thread since the solutions did not help me out.

What I am trying to achieve? - For every Marketo form with a landing page that is submitted I want to send an event to GA passing the form id.

 

What I am doing currently? - On the Marketo landing page I am writing this piece of code within an html box element.

<script src="//app-ab24.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_1234"></form>
<script>MktoForms2.loadForm("//app-ab24.marketo.com",
"123-XYZ-456",
1234,


function(form){
form.onSuccess(
function(values, thankYouUrl){
ga("send", {
hitType : "event",
hitCallback : function() {
document.location.href = thankYouUrl;
},
eventAction : "Submitted",
eventCategory : "Marketo Form",
eventLabel : form.getId()
}
);
}
);
}


);</script>

 

What is output am I seeing? - In GA I see a pageview for my landing page. No event is sent.

 

Can anyone suggest what modifications I can try to make this work?

Thanks in advance!

Outcomes