Skip to main content
Level 4
January 20, 2015
Question

How to auto fill hidden field with forms 2.0

  • January 20, 2015
  • 5 replies
  • 2091 views
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>
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

5 replies

Kristen_Malkov1
Level 7
January 20, 2015
You can easily have the hidden field populate off of the URL that directed them to the form. Is that an option for you?
Level 4
January 20, 2015
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
January 20, 2015
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
Adobe Employee
Adobe Employee
January 20, 2015
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.
Level 4
January 21, 2015
Thanks for the responses everyone