SOLVED

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

Go to solution
SanfordWhiteman
Level 10 - Community Moderator

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

It's MktoForms2.whenReady (period, not comma).

Nate_Oosterhous
Level 7

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

Hi Sanford.  I made that switch and it still does not work.  Any ideas?

SanfordWhiteman
Level 10 - Community Moderator

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

Post a link to your page so I can see the JS console.  Hard to know without that.

Nate_Oosterhous
Level 7

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

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

Nate_Oosterhous
Level 7

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

You guys are awesome!  It worked.  I have one more thing.  Is there anyway to remove UTM parameters so it is a bare URL?

Kenny_Elkington
Marketo Employee

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

You can change document.location to document.location.toString.split('?')[0]

Nate_Oosterhous
Level 7

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

Here is what I have but it is not removing the UTM parameters:

<script>

MktoForms2.whenReady(function(form){

     form.addHiddenFields({"Latest_Form_Form_Webpage__c":document.location.toString.split('?')[0]});

})

</script>

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.toString().split('?')[0]

or (my preference)

document.location.href.split('?')[0]

Nate_Oosterhous
Level 7

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

Kenny and Sanford thank you for your help!  You guys are awesome!