Want to populate a field that has the actual URL a web form is filled out on. | Community
Skip to main content
Level 7
September 9, 2015
Solved

Want to populate a field that has the actual URL a web form is filled out on.

  • September 9, 2015
  • 2 replies
  • 5300 views

For our Marketo Landing Pages with Forms on them we want to capture what webpage url the form was filled out on.  {{trigger.Web Page}} does not work because that only give the Marketo description name.  We need the full url of the Landing Page.  How can we do this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

pages.hexarmor.com/rig-lizard-2021.html

Thanks Sanford


Actually, our bad, do

form.addHiddenFields

not

form.vals

2 replies

Kenny_Elkington
Adobe Employee
Adobe Employee
September 9, 2015

You'll need to use a script to populate this field, something like this:

<script>

MktoForms2,whenReady(function(form){

     form.vals({"yourFieldApiName":document.location});

})

</script>

This will add the URL of the page into the specified field, yourFieldApiName.

SanfordWhiteman
Level 10
September 9, 2015

document.location tho

June 28, 2016

Hi there, is there a way to implement this script on the form itself?

SanfordWhiteman
Level 10
June 28, 2016

Yes, but I wouldn't recommend it.   See my thoughts on this other thread from just today: Is it okay to use javascript in rich text fields in forms?

September 9, 2016

Sanford I think you can help me out.

I'm looking at creating a global form for gated content and using the URL to route users to the correct content.

I may be in a bit over my head right now, but maybe you can help me out.

I placed the below into a RT field in the form... based on this thread

<script>

MktoForms2.whenReady(function(form){

     form.addHiddenFields({"Latest_Form_Fill_Webpage":document.location});

})

</script>

I'm pretty sure my implementation is wrong for a few reasons.

1. when I save the RT field, marketo automatically adds to the code //[Cdata! ....

2. I think Mkto.Forms2.whenReady() only runs on submit? I'm not sure and don't know where to find documentation right now.

Thoughts?

Should I avoid using the JS in the Form Rt and just implement in the footer of all my wordpress pages + MKTO landing page templates?