GA Event for Marketo Form Submission | Community
Skip to main content
Anuja_Jadhav
Level 2
April 5, 2019
Question

GA Event for Marketo Form Submission

  • April 5, 2019
  • 2 replies
  • 4787 views

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!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

SanfordWhiteman
Level 10
April 5, 2019

Please highlight your code so it's readable.

https://s3.amazonaws.com/blog-images-teknkl-com/syntax_highlighter.gif

SanfordWhiteman
Level 10
April 5, 2019

Please add a comment once you've made the code readable, so I know to check back.

You should also include a link to your page so I can check that you've deployed the code properly.

Anuja_Jadhav
Level 2
April 5, 2019

@Sanford Whiteman​

I have highlighted the code and here is my page link: https://go.takarabio.com/jadhavaTestCampaign_test.html

SanfordWhiteman
Level 10
April 5, 2019

Please note the console error:

That's because you don't have GA loaded on the page. As a result, the onSuccess listener errors out (never gets a chance to return), and the default success action proceeds.