AnsweredAssumed Answered

Issue with Submitting marketo forms with events in GA

Question asked by Manish Khemani on Nov 9, 2016
Latest reply on Nov 10, 2016 by Sanford Whiteman

Hello There,


I have created a Marketo Form and inserted its embed code in the (External) Landing page


Also, I have added code for from validation - to restrict any personal email ids i.e. gmail, hotmail, etc. - This is working fine.


We also need a ga event (ga('send', 'event', 'Download', 'Click', 'GTS-2016-Download');) fired on Successful form fill; for this we have used the onSuccess handler, But the event is NOT firing; Attaching the code used in Title of the document below: Could Anyone guide what is that We are doing Wrongly to not fire the Event. We have implemented GA code via GTM in the head section of the page.



<form id="mktoForm_3683">

<div style="margin-left:275px; margin-bottom:10px;">

<script src="" type="text/javascript" async></script><script type="IN/Form2" data-form="mktoForm_3683" data-field-firstname="FirstName" data-field-lastname="LastName" data-field-phone="MobilePhone" data-field-email="Email" data-field-company="Company" data-field-title="Title"></script>



<link type="text/css" rel="stylesheet" href="form2.css" />

<script>MktoForms2.loadForm("//", "120-PTN-868", 3683, function (form){MktoForms2.lightbox(form).show();});</script>


(function (){

  var invalidDomains = ["@gmail.","@yahoo.","@hotmail.","@live.","@aol.","@outlook."];



  MktoForms2.whenReady(function (form){


    ReferringSite : document.referrer



      var email = form.vals().Email;


        if(!isEmailGood(email)) {


          var emailElem = form.getFormElem().find("#Email");

          form.showErrorMessage("Please use your business email. Thank you!", emailElem);






  /* --------------------------------------------- */

  form.onSuccess(function (values, url){

  /////var url ="" ( ;



  //alert("VAL :"+values);

  //alert("URL :"+url);

                    // Send a "Event" to google analytics to trigger a premium content download for this piece of content

                    ga('send', 'event', 'Download', 'Click', 'GTS-2016-Study-Known-User');





                    // Opens the form's Follow Up URL on successful completion (the asset is specified in the Marketo form config)

                    ////, 'myWindow');


                    // add the custom thank you message and download link to the actual asset



                   //// var thankYou = "";

                    ////form.getFormElem().before("<p style='padding:10px;width:283px;font-size:14px;color:white;height:100px;text-align:center'>Thank you for downloading.<br/><br/>Your content will open in a new window.</p>"); 

                    return true;


    /* --------------------------------------------- */



  function isEmailGood(email) {

    for(var i=0; i < invalidDomains.length; i++) {

      var domain = invalidDomains[i];

      if (email.indexOf(domain) != -1) {

        return false;



    return true;