Sumbission of marketo forms showing as events in GA, preferably using GTM | Community
Skip to main content
March 17, 2015
Question

Sumbission of marketo forms showing as events in GA, preferably using GTM

  • March 17, 2015
  • 23 replies
  • 3966 views
I am just wanting to fire an event to GA on the submission of a form. What is the best way to do this?
If possible i would like to use Google Tag Manager to do it.
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

23 replies

March 18, 2015
its still not working for me,
I was not entirly sure what you meant by return true; , I am not very technical
I tried a few variations of what i thought you might mean but non worked. 

Here is the exact code I am trying: 
<div class="FormLightbox">
<a class="btCloseLightbox" href="javascript:;"><span>X</span></a>
<h1>Tell us about yourself</h1>

<p>
This ebook is yours for free. Just enter your details below, and you'll have access to the entire RED resource library!</p>

<script src="//app-sj07.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_456"></form>
<script>MktoForms2.loadForm("//app-sj07.marketo.com", "801-TVW-591", 456, function(form){
    form.onSuccess(function(form){
        _gaq.push.
 true;('_trackEvent' 
            , 'PDF' 
            , 'Downloaded' 
            , 'PDF On HOw To Turn HR into a Profit Center Downloaded');
        });
});
SanfordWhiteman
Level 10
March 18, 2015
You must still be leaving something out of the exact code. :)  Or you deleted the final </script>.

This is where you put return true; to tell Forms 2.0 to also redirect to the Thank You URL:

function(form){
    form.onSuccess(function(form){
        _gaq.push('_trackEvent' 
            , 'PDF' 
            , 'Downloaded' 
            , 'PDF On HOw To Turn HR into a Profit Center Downloaded');
        });
        return true;

});


 
March 20, 2015
this is what i have now but it still isnt letting the form submit...


<div class="FormLightbox">
<a class="btCloseLightbox" href="javascript:;"><span>X</span></a>
<h1>Tell us about yourself</h1>

<p>
This ebook is yours for free. Just enter your details below, and you'll have access to the entire RED resource library!</p>

<script src="//app-sj07.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_456"></form>
<script>MktoForms2.loadForm("//app-sj07.marketo.com", "801-TVW-591", 456, function(form){
    form.onSuccess(function(form){
        _gaq.push
 true;('_trackEvent' 
            , 'PDF' 
            , 'Downloaded' 
            , 'PDF On HOw To Turn HR into a Profit Center Downloaded');
        });
return true;
});
</script>

 
SanfordWhiteman
Level 10
March 20, 2015
Well, you have an errrant "true;" in your code, so there's probably a syntax error.  I hope you're looking at your browser's console/developer tools to see such things.

The correct code is demoed here.  The onSuccess is called as expected.  However since that page doesn't have your GTM code, it fails (understandably) on the line that calls _gaq.push().  

If you post the actual URL of your page I could take another look.
March 20, 2015
I have fixed it now so that the code is firing, however the event is not coming through in GA......

here is what i am using:
<script src="//app-sj07.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_456"></form>
<script>MktoForms2.loadForm("//app-sj07.marketo.com", "801-TVW-591", 456, function(form){
 form.onSuccess(function(form){
     ga('send', 'event', {
      eventCategory: 'PDF',
      eventAction: 'Downloaded',
      eventLabel: 'PDF On HOw To Turn HR into a Profit Center Downloaded'
       });
     });
    return true;
  });
</script>

 
March 20, 2015
the page we are running it on is this one:
http://www.recogniseeveryday.com.au/why-recognition/articles-videos/turning-hr-into-a-profit-centre-how-to-calculate-the-roi-of-your-recognition-program/
SanfordWhiteman
Level 10
March 20, 2015
On that page, I don't see any onSuccess handler.

I only see the default embed code:

<script>MktoForms2.loadForm("//app-sj07.marketo.com", "801-TVW-591", 456);</script>
March 22, 2015
i have it in there, or is there an additional element that needs to go in?

<script src="//app-sj07.marketo.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_456"></form>
<script>MktoForms2.loadForm("//app-sj07.marketo.com", "801-TVW-591", 456, function(form){
 form.onSuccess(function(form){
     ga('send', 'event', {
      eventCategory: 'PDF',
      eventAction: 'Downloaded',
      eventLabel: 'PDF On HOw To Turn HR into a Profit Center Downloaded'
       });
     });
    return true;
  });
</script>
SanfordWhiteman
Level 10
March 22, 2015
That looks right (I'm on my mobile, though, so I can't check the console). What do you see in the console when you submit now?
March 22, 2015
No, its still not working, I cannot figure out for the life of me why not.....