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

Anonymous
Not applicable

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

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.
Tags (1)
24 REPLIES 24
Anonymous
Not applicable

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

I should also mention, we are using a marketo form in a lightbox over a non marketo landing page
SanfordWhiteman
Level 10 - Community Moderator

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

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).
Anonymous
Not applicable

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

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 - Community Moderator

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

@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.
Anonymous
Not applicable

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

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 - Community Moderator

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

You should use onSuccess:

form.onSuccess(function(form){
    _gaq.push( ... );
});
Anonymous
Not applicable

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

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 - Community Moderator

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

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');
        });
});
Anonymous
Not applicable

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

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?