Embedded Forms - Send user to PDF - Not remembering user on subsequent visit

Anonymous
Not applicable

Embedded Forms - Send user to PDF - Not remembering user on subsequent visit

Hi there,

I have the following issue:

We are using embedded forms. In some cases we offer the user a PDF after they fill out the form and we send them directly to the PDF file after they hit submit.

In these cases, when the user navigates to a different form on our website, the Marketo form does not recognize them and so they have to fill out the form again.

In other cases we offer them a different page on our website ("thank you page variant") and in such cases when they visit other pages on our website the form recognized them and they do not need to fill out, they just hit submit.

Correct me if I am wrong, but my assumption is that since there is no Munchkin code being fired when they visit a PDF Marketo does not register their form success??

If my assumption is correct, can I add some javascript to my forms so that when linking to a PDF we also have get the functionality of logging the user back in to the form when they visit a subsequent page on our website?

If yes, any code examples?

Thanks so much for reading this far 🙂

2 REPLIES 2
Anonymous
Not applicable

Re: Embedded Forms - Send user to PDF - Not remembering user on subsequent visit

Here is an example of my current code:

<script>MktoForms2.loadForm("//app-sj09.marketo.com", "523-VNL-345", 1420,

  function(form) {  

  for ( var ss = document.styleSheets, i = 0, imax = ss.length; i < imax; i++ ) {

  if ( ( ss[i].href && ss[i].href.indexOf("marketo.com") !== -1 )

  || ( (ss[i].ownerNode || ss[i].owningElement).parentNode == form.getFormElem()[0] ) ) {

  }

  }

  form.onSuccess(function(values, followUpUrl){

  location.href = "https://www.example.com/Example-File.pdf";

  if("https://www.example.com/Example-File.pdf".match(/\.(pdf|ppt|pptx|doc|docx)/g)) {

  window.dataLayer = window.dataLayer || [];

  dataLayer.push({"event":"link-click"});

  }

  return false;

  });

  });

  </script>

SanfordWhiteman
Level 10 - Community Moderator

Re: Embedded Forms - Send user to PDF - Not remembering user on subsequent visit

First, don't know what you're doing with that stylesheet-related code in there! It's not serving a purpose.

Second, this will never work as expected:

  location.href = "https://www.example.com/Example-File.pdf";

  if("https://www.example.com/Example-File.pdf".match(/\.(pdf|ppt|pptx|doc|docx)/g)) {

  window.dataLayer = window.dataLayer || [];

  dataLayer.push({"event":"link-click"});

  }

  return false;

Setting location.href is synchronous. That means the page starts unloading immediately and you cannot expect any lines of code after that one to run at all.  Your dataLayer.push is not functional.

Third, to get to the idea of "not remembering the user," you haven't mentioned whether you're using different forms in different parts of the site. Only if a form has "If known lead, show Custom HTML" selected (in Settings) will the form be suppressed. This is a form-by-form setting.