Skip to main content
Level 4
Feb 19, 2021 11:08 AM UTC
Solved

Script for passing the page url on to a Marketo field

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?

13 replies

SanfordWhiteman
User Group Leader
SanfordWhitemanUser Group LeaderAccepted solution
User Group Leader
Feb 19, 2021 2:18 PM UTC
SarinAuthor
Level 4
Feb 20, 2021 4:20 AM UTC

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 });
});

 

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Feb 20, 2021 9:04 AM UTC

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.

Translate