AnsweredAssumed Answered

Re-submit a form on button click with cookied user

Question asked by Mark Gill on Jan 3, 2019
Latest reply on Jan 3, 2019 by Sanford Whiteman



I am currently integrating Marketo forms to a website. After filling out the form the user is presented with a download button.


The setup:

JS embeds with custom HTML with a "download" button.

User fills out the form and is presented with the download button.

On button click user should receive the asset.

Assets are hosted on the website, not with Marketo.

When the user clicks the button the form should submit again in the background and the user receives the asset.





After submitting we are using an additional cookie to perform a lot of frontend swaps and changes

Once the user fills the form one time they have access to all assets, by clicking the download button on another page it should re-submit the form with the users information, tracking them from page to page (download to download) through form submissions.


The issue I am having is re-submitting the form with the user after the initial form fill.

The user goes to a new page, they are cookied by Marketo so the form shows the custom HTML download button. When clicking the download button I would like to do a form submission with the cookied users data.



MktoForms2.loadForm("//", "910-ISZ----", ----, function(form){
     var thankYouWindow;
     var check = Cookies.get("myCookie");
     var notYou = jQuery('#mktoNotYou');
     var btn = document.getElementById("mktoButton");{
     if(check === 'unlocked'){
          btn.onclick = function() {
               thankYouWindow ='');
               var download = jQuery('.locked').data('download');
               thankYouWindow.document.location = download;

              // I had hoped
             //  MktoForms2.whenReady(function (form) {
            //        form.submit();
           //    });
          // would work, but doesn't seem to. Even though Marketo has the user cookied in order to show them this button, 
         // I don't think it is pre-filling the form with the users data for re-submission.

     } else {
     form.onSuccess(function(values, followUpUrl) {
          var all = jQuery('.alllock');
          if (all) {
               jQuery.each(all, function() {
     Cookies.set('myCookie', 'unlocked');
     return false;

Is there a way to re-submit a form outside perhaps saving all the data to a variable and re-populating the form manually and then submitting?