AnsweredAssumed Answered

GA event tracking for onSuccess

Question asked by Thomas Rosen on Apr 18, 2018
Latest reply on Apr 18, 2018 by Sanford Whiteman

I am trying to figure out what's wrong with my landing page. I am trying to keep the on-page thank you message and send a GA event. I have the thank you working as expected, but the GA event is not firing.

 

Here is the code that I'm using:

 

<script src="//app-ab14.marketo.com/js/forms2/js/forms2.js"></script>

<script>

MktoForms2.whenReady(function (form){

//Add an onSuccess handler

form.onSuccess(function(values, followUpUrl){

//GA event trigger

if ( 'YES' == '${z-TriggerGAEvent}') {

ga('send','event','${z-GAEventCategory}','${z-GAEventAction}','marketo');       

              }

//get the form's jQuery element and hide it

form.getFormElem().hide();

    document.getElementById('confirmform').style.visibility = 'visible';

    //return false to prevent the submission handler from taking the lead to the follow up url.

    return false;

  });

});

</script>

 

The landing page lives here.

 

Any suggestions are much appreciated.

 

Thanks,

Thomas

Outcomes