Re: How to auto fill hidden field with forms 2.0

John_Wallace
Level 4

How to auto fill hidden field with forms 2.0

Hi there,  I am interested creating multiple variations of the same landing page but passing in different refferal urls within the form.  We are using forms 2.0 and my thought was to have it auto fill the hidden field that contains the referral field.  This is kinda of what I am thinking but was not sure about the syntax for hidden fields or especially hidden ref fields.  Has anyone done this before?  any suggestions would be apprecited.  Thanks
-John

<script src="//app-sjp.marketo.com/js/forms2/js/forms2.js"></script>
<form id="mktoForm_161"></form>
<script>MktoForms2.loadForm("//app-sjp.marketo.com", "466-AGZ-592", 161, function(form){
form.vals({ "Ref":"myreferral-code-here"});
});</script>
Tags (1)
5 REPLIES 5
Kristen_Malkov1
Level 8

Re: How to auto fill hidden field with forms 2.0

You can easily have the hidden field populate off of the URL that directed them to the form. Is that an option for you?
John_Wallace
Level 4

Re: How to auto fill hidden field with forms 2.0

The marketing team wants to use ref codes to track which users visit different campaigns that come in from Perfect Audience, google adwords, and apm digest advertisments.   so I think it goes deeper than just a url and it somehow tracks from what advertisment vender we use.  But I will check with them because I am sure populating the url would be a lot easier.  Thanks for the response.

-John
Anonymous
Not applicable

Re: How to auto fill hidden field with forms 2.0

I agree regarding populating your hidden fields off of URL values.  We just use UTM tags on our urls, which you can use to distinguish different campaign sources, etc.

https://support.google.com/analytics/answer/1033867?hl=en
 
Kenny_Elkington
Marketo Employee

Re: How to auto fill hidden field with forms 2.0

Hey John,

If the form does not load the field which you're trying to set by default, you'll need to use the addHiddenFields method instead of the vals methods to populate these.  vals will not create new fields, just set the values for available fields.
John_Wallace
Level 4

Re: How to auto fill hidden field with forms 2.0

Thanks for the responses everyone