SOLVED

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

Go to solution
SanfordWhiteman
Level 10 - Community Moderator

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

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.
Leanne_Persang
Level 4

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

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.

SanfordWhiteman
Level 10 - Community Moderator

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

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).

Leanne_Persang
Level 4

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

Hi Sanford,

I tried Kenny's suggestion of a campaign above and it worked - I did not need any additional code.

"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}}"

I referenced the trigger token in the alert email so the team knows what product page the end user filled out the form on.

Thanks for your help.

SanfordWhiteman
Level 10 - Community Moderator

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

The point is that you need *either* the SC or the JS API code. The code is more efficient because it doesn't mean another trigger is active in your instance.

Anonymous
Not applicable

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

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?

Grégoire_Miche2
Level 10

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

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