Skip to main content
Level 7
Mar 19, 2015 3:56 PM UTC
Solved

How to create a field that grabs the web page the form was filled out on?

Hello Everyone!

We are looking at creating a field that will grab the web page the form was filled out on.  We then would like to add this as a token in and alert that goes to sales when a form is filled out?  Do anyone have any ideas of how to accomplish this?
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
Mar 19, 2015 8:26 PM UTC
@Nate O Easily done with a hidden field.

MktoForms2.loadForm("//app-**01.marketo.com", "***-***-***", 148,
    function(form) 
    {
        form.addHiddenFields({ LastFormURL : document.location.href })    
    });
 

16 replies

Kenny_Elkington
Adobe Employee
Adobe Employee
Mar 19, 2015 3:58 PM UTC
Hey Nate,

You'll want to create a smart campaign with Smart List Fills Out Form, and Flow, Change Data Value, MyField, New Attribute is {{trigger.Web Page}}
Translate
Level 7
Mar 19, 2015 4:57 PM UTC
Hi Kenny,

I tried that and it doesn't populate the field.  It would be an external web page that we want to populate the field with because the form is on an external web page.  Any ideas?
Translate
SanfordWhiteman
User Group Leader
SanfordWhitemanUser Group LeaderAccepted solution
User Group Leader
Mar 19, 2015 8:26 PM UTC
@Nate O Easily done with a hidden field.

MktoForms2.loadForm("//app-**01.marketo.com", "***-***-***", 148,
    function(form) 
    {
        form.addHiddenFields({ LastFormURL : document.location.href })    
    });
 
Translate
Tim_Marcacci
Level 2
Apr 17, 2017 11:52 PM UTC

@Sanford Whiteman I know it's been a few years since you posted this, but it was EXACTLY what I was looking for. Dropped the code right in and everything worked flawlessly. Thank you, Sir!!!

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Apr 18, 2017 12:33 AM UTC

Great to hear!

Translate
Level 7
Mar 20, 2015 1:38 PM UTC
Hi Sanford,

Would I have our developer put that whole code just like it is with the asterisks and everything in the form we have embedded on multiple external web pages?
Translate
SanfordWhiteman
User Group Leader
User Group Leader
Mar 20, 2015 2:35 PM UTC
The asterisks represent your company's Marketo data (your Munchkin ID and Marketo instance). Your developer will know what to do if s/he is already using the embed code.
Translate
cjdst273
Level 4
Dec 13, 2016 10:04 PM UTC

Hi Sanford,

So only this code is needed to trace the last form URL? And, the webmaster will know what to put in the asterisks?

MktoForms2.loadForm("//app-**01.marketo.com", "***-***-***", 148,

    function(form)

    {

        form.addHiddenFields({ LastFormURL : document.location.href })   

    });

Then, I also need to create a smart campaign with Smart List Fills Out Form, and Flow, Change Data Value, MyField, New Attribute is {{trigger.Web Page}}? For the MyField I created a custom "Web Page Source" field, which I can add to my alert email.

Translate
SanfordWhiteman
User Group Leader
User Group Leader
Dec 13, 2016 10:27 PM UTC

No, you don't need a Smart Campaign.  You just need the field LastFormURL (String) to exist in your instance (you can call it anything you want, just make sure the code reflects the same field name).

Translate
Mar 1, 2018 8:11 AM UTC

Hi,

I know this is not a recent thread.

But where do you actually place the Javascript code? In the marketo form? Where how? or on your website page?

Translate
Grégoire_Miche2
Level 10
Mar 1, 2018 11:18 AM UTC

HI Benedicte,

depends on whether you are using it in a Marketo LP or in an embedded form.

In a Marketo LP, you will have to edit the template a put this at the end, before the </body> tag :

<script>

MktoForms2.whenReady(function (form) {

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

});

</script>

In an embedded form, you will have to modify the embed code as shown by Sanford

-Greg

Translate