SOLVED

Issue with Javascript on Page

Go to solution
kenmckown
Level 4

Issue with Javascript on Page

We have an external LP that has a Marketo form on it. We have custom JS on the page that is redirecting depending on a field that is written, but I noticed the field is no longer writing, even though the submission is telling it to. Not sure what happened, as it worked before.

 

This is the JS code:

<script src="//go.autoshopsolutions.com/js/forms2/js/forms2.min.js"></script>
<form id="mktoForm_3948"></form>
<script>
MktoForms2.loadForm("//go.autoshopsolutions.com", "180-DGD-014", 3948, function(form){
  // Add hidden field
  form.addHiddenFields({ lastFormURL : document.location.href });
  // Override redirect on success
  form.onSuccess(function(values, followUpUrl){
    // Custom redirect URL
    window.location.href = "https://shopboss.net/thank-you/?source=unbounce";
    return false; // prevent default redirect
  });
});
</script>
<script>
{
  const ctaText = "Download Now";
  /* -- NO NEED TO TOUCH BELOW HERE -- */
  MktoForms2.whenReady(function(readyForm){
    const formEl = readyForm.getFormElem()[0],
          buttonEl = formEl.querySelector(".mktoButton[type='submit']");
    buttonEl.textContent = ctaText;
  });
}
</script>

I checked activity and it appears it is creating a new field, instead of updating the current one:

kenmckown_0-1756475259368.png

The field in Marketo should be this one:

kenmckown_1-1756475355882.png

I am wondering if the code just needs to be updated to lastFormUrl to map to the field on the form.

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Issue with Javascript on Page

JavaScript names are case-sensitive.

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: Issue with Javascript on Page

JavaScript names are case-sensitive.

kenmckown
Level 4

Re: Issue with Javascript on Page

That is what I thought the issue was as well, thanks for confirming.