Forms 2.0 : Tracking a Submit button as an Event in GA Universal

Jean-Pascal_Mer
Level 4

Forms 2.0 : Tracking a Submit button as an Event in GA Universal

Hi guys,

We have forms that I would need to track in Google Analytics Universal as Events when someone click the Submit buttons.

There is no thank you page, so I can't use the Destination goal.

As anyone figured any way to do so?

Thanks

JP
Tags (1)
5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: Forms 2.0 : Tracking a Submit button as an Event in GA Universal

Just did this with a client the other day.  Add your _ga calls inside the onSuccess handler as described in the docs.
Jean-Pascal_Mer
Level 4

Re: Forms 2.0 : Tracking a Submit button as an Event in GA Universal

So my code should look like this? 

<script src="//app-ab08.marketo.com/js/forms2/js/forms2.js"></script>
<form id="mktoForm_1007"></form>
<script>
MktoForms2.loadForm("//app-sjo.marketo.com", "288-VQZ-957", 1007, function(form){
form.onSuccess(function(values, followUpUrl){
form.getFormElem().hide();
ga('send', 'event', 'button', 'submit', 'infokit');
$('.message-marketo').show();
return false;});
});
</script>

If so, it doesn't seem to fire but I'm not sure if the order of the calls is the problem here.
SanfordWhiteman
Level 10 - Community Moderator

Re: Forms 2.0 : Tracking a Submit button as an Event in GA Universal

I would assume you are getting some errors in the Dev Console (rather than it silently failing).  Take a look at those.
Mihai_Bejgu
Level 3

Re: Forms 2.0 : Tracking a Submit button as an Event in GA Universal

I have the same situation, but I'm using an iframe instead of full Landing Page and form. Do you have a solution for that?

Kind regards,

Mihai

SanfordWhiteman
Level 10 - Community Moderator

Re: Forms 2.0 : Tracking a Submit button as an Event in GA Universal

Please open a new thread and provide more information, including a URL. We can't troubleshoot JS without looking at code.