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 17, 2015
I should also mention, we are using a marketo form in a lightbox over a non marketo landing page
SanfordWhiteman
Level 10
March 17, 2015
I'd do any followup calls in the onSuccess handler because that way you are logging a successful form post, rather than just an attempted one as in onSubmit (not that failure is common, but it's the proper way).
March 17, 2015
Hey James,

With Google Tag Manager, you can setup listeners that tracks Form success on any page GTM is installed on. You can then use that as an event in Google Analytics, or any of the other tags installed.

https://support.google.com/tagmanager/answer/3415369?hl=en
SanfordWhiteman
Level 10
March 17, 2015
@Max S I would not advise using a dumb event listener that may think any submit button click == successful submit.

The only way to get a proper accounting of successful submits that pass validation and reach the Marketo servers is to use the supplied onSuccess event.
March 17, 2015
I agree with Sanford that I only want to know when people have successfully submitted the form. 
So Sanford would you say i just need to change the embed code to be something like:

<script>MktoForms2.loadForm("//app-sjqe.marketo.com", "718-GIV-198", 621, function(form){
form.onSubmit(_gaq.push(['_trackEvent' , 'PDF' , 'Downloaded' , 'PDF On how to dowload(){
});
</script>

 
SanfordWhiteman
Level 10
March 18, 2015
You should use onSuccess:

form.onSuccess(function(form){
    _gaq.push( ... );
});
March 18, 2015
I have tried the exact code below but for some reason when I deploy it it stops the form from appearing. Any ideas of what is wrong with it?

<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){from.onSuccess(function(form){_gaq.push('_trackEvent' , 'PDF' , 'Downloaded' , 'PDF On HOw To Turn HR into a Profit Center Downloaded');});
</script>
SanfordWhiteman
Level 10
March 18, 2015
Typo... "from" != "form"

Also, you may have mismatched braces:

MktoForms2.loadForm("//app-sj07.marketo.com", "801-TVW-591", 456, function(form){
    form.onSuccess(function(form){
        _gaq.push('_trackEvent' 
            , 'PDF' 
            , 'Downloaded' 
            , 'PDF On HOw To Turn HR into a Profit Center Downloaded');
        });
});
March 18, 2015
Whoops, sorry about that.
I made the suggested alterations and the form appeared again. However now it is not not directing people to the follow up page that is in the settings. 

What do I need to do to bring back the follow up page in addition to the event tracking?
SanfordWhiteman
Level 10
March 18, 2015
Add return true; after the _gaq.push line.