Script for passing the page url on to a Marketo field | Community
Skip to main content
Level 4
February 19, 2021
Solved

Script for passing the page url on to a Marketo field

  • February 19, 2021
  • 1 reply
  • 5370 views

We would like to capture and store the most recent page url (from which the lead filled out the form in a Marketo field).  Does anyone have the script for the same?

1 reply

SarinAuthor
Level 4
February 20, 2021

Thanks a lot  @sanfordwhiteman 🙂

 

Could you provide the complete script please and also tell us how to implement it on both external as well as Marketo landing pages (Guided template)

 

I assumed we need to add some more code to the below:

MktoForms2.whenReady(function (form) {
    form.addHiddenFields({ LastFormURL : document.location.href });
});

 

SanfordWhiteman
Level 10
February 20, 2021

No, that's the code. There's nothing else.

 

Simply make sure that code runs after the embed code. On non-Marketo pages: put it anywhere after the embed code (since you control placement). On Marketo LPs: put it just above the closing </body> tag.