SOLVED

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

Go to solution
Nate_Oosterhous
Level 7

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

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?

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

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

Actually, our bad, do

form.addHiddenFields

not

form.vals

View solution in original post

28 REPLIES 28
Kenny_Elkington
Marketo Employee

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

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 - Community Moderator

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

document.location tho

Kenny_Elkington
Marketo Employee

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

I've got a one track mind these days.  Fixed.

SanfordWhiteman
Level 10 - Community Moderator

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

I don't think I could ever love/hate anyone as much as I love/hate documentation. If you're in a doc groove, I'm jealous.

Nate_Oosterhous
Level 7

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

Hi Kenny.  I am not a developer.  Where would I specifically add this script?  Thanks!

Kenny_Elkington
Marketo Employee

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

You can just add an HTML block to your page and input the script there.  The block should be ordered after your form.

Nate_Oosterhous
Level 7

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

This would just be the Marketo Landing Page template HTML correct?

Kenny_Elkington
Marketo Employee

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

No the page itself, not the template, unless you want this behavior to occur with all forms on pages based on that template.

Nate_Oosterhous
Level 7

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

Hello again Kenny.  Below is my script I added as an HTML block and it is below the form block.  For some reason it isn't populating that custom field.

<script>

MktoForms2,whenReady(function(form){

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

})

</script>