Using a campaign specific token in a hidden field on a multi-use form

Anonymous
Not applicable

Using a campaign specific token in a hidden field on a multi-use form

Hello all,

I did some research before I decided to post this as I was not able to find an appropriate solution.

Here is our use case:

- We would like to build one form with a hidden field that we would like to populate with a token {{my.parameter}}

- We would then want to use that form in many future Marketo Hosted Landing pages tied to corresponding trigger campaign

    Each program specific to different projects.  We would want to just replicate the programs and update the {{my.parameter}} token value each time instead of having to duplicate the form each time. 

Is this scenario possible to pass a value through the token {{my.parameter}} into the hidden field and captured each time the form is submitted.

I don't think I can do this with the answer provided in this thread:  token in fields possible?

thanks for your help.

7 REPLIES 7
SanfordWhiteman
Level 10 - Community Moderator

Re: Using a campaign specific token in a hidden field on a multi-use form

If the LPs are program-local assets, then you can use the {{my.token}} to set the hidden field. Doesn't matter if the form is global.

MktoForms2.whenReady(function(form){

  form.addHiddenFields({

    fieldName: "{{my.token}}"

  });

});

Anonymous
Not applicable

Re: Using a campaign specific token in a hidden field on a multi-use form

Thank you Sanford!  I will give this a try and confirm.

regards,

Nghi

Anonymous
Not applicable

Re: Using a campaign specific token in a hidden field on a multi-use form

Hi Sanford,

how do I construct the statement on the landing page html to set a value to {{my.token}} so that when the person submits the form on the landing page, the value passes through to the hidden field in the form and then finally to the submission data?
thanks

Nghi

SanfordWhiteman
Level 10 - Community Moderator

Re: Using a campaign specific token in a hidden field on a multi-use form

? That's exactly what the code above does.  Just wrap it in <script></script> tags and make sure it appears after the <script> that loads forms2.min.js (putting it just before the closing </body> tag will do this).

Anonymous
Not applicable

Re: Using a campaign specific token in a hidden field on a multi-use form

Ok, thanks!

Kim_Gandy1
Level 7

Re: Using a campaign specific token in a hidden field on a multi-use form

Sanford Whiteman​, if I'm auto-filling hidden field with {{lead.Inferred Country}} token, where should I get the value from? Cookie?

SanfordWhiteman
Level 10 - Community Moderator

Re: Using a campaign specific token in a hidden field on a multi-use form

You'd fill the hidden field from the {{lead.token}} using the exact same code I used above for the {{my.token}}.

You can't obtain token values from cookies. That wouldn't make sense, they're stored on the lead record.