Skip to main content
Prefill Fields
Giancarlo Massaro avatar
Written by Giancarlo Massaro
Updated over a week ago

Need to prefill just email addresses that you already have? See Prefill Email Address.

Want to automatically submit the form after prefilling the fields? See Auto Submit Forms.


Prefilling fields allows you to pass data into our form without having the user enter their information. Typically you would do this if you are directing users to the campaign after they have signed into your site or completed some other type of form before seeing the ViralSweep entry form.

Javascript Implementation

Using the script below, you can prefill any fields that you would like, including custom fields. Simply include this script on the page right before the actual script for the campaign style you are using (full page, widget, or lightbox).

For custom fields, you will need to add the fields to your entry form first, then visit your entry form, and using the browser inspect tool, select the field and find its ID. If you need assistance with this, please contact us.

<script><!--//change widget to full or lightbox depending on which style you are using-->function vs_widget_load_callback(){vs_prefill_field('first_name','John');vs_prefill_field('last_name','Smith');vs_prefill_field('email','[email protected]');vs_prefill_field('address','23 Main St');vs_prefill_field('address2','Apt 3');vs_prefill_field('city','Austin');vs_prefill_field('state','Texas');vs_prefill_field('zip','78704');vs_prefill_field('country','United States of America');vs_prefill_field('phone','2221111234');vs_prefill_field('birthday_month','May');vs_prefill_field('birthday_day','12');vs_prefill_field('birthday_year','1985');vs_prefill_field('code','1234');vs_prefill_field('18940_1525208752','This is a custom field example-don't copy.');}</script>

To pass dynamic values into these fields, you would simply replace the preset values with whatever values you have for the particular user that is visiting the page.

Please also note, when passing data for state and country, the data you pass must match what we have in our system (for example, if you pass USA it will not prefill, but United States of America will prefill).

URL Parameters Implementation

To prefill fields using the URL parameters implementation, you simply need to add the parameters you want to pass on the end of our provided URL. The parameters that can be used are as follows:

[email protected]_first_name=Joevs_last_name=Smithvs_phone=2223334444vs_address=1234 my streetvs_address2=apt3vs_city=Austinvs_state=Texasvs_zip=12345vs_birthday_month=Decembervs_birthday_day=8vs_birthday_year=1980vs_country=United States of Americavs_code=1234

A working example would use our direct link that we provide, and have any of the above parameters appended to it.

To append all these fields we add:

&vs_first_name=Josh&vs_last_name=Smith&[email protected]&vs_phone=1234567899&vs_address=123 my street&vs_address2=apt3&vs_city=Austin&vs_state=Texas&vs_zip=12345&vs_birthday_month=December&vs_birthday_day=8&vs_birthday_year=1980&vs_country=United States of America&vs_code=1234

Our final link looks like this:

https://app.viralsweep.com/vrlswp/full/d7f01f-70537?framed=1&vs_first_name=Josh&vs_last_name=Smith&[email protected]&vs_phone=1234567899&vs_address=123%20my%20street&vs_address2=apt%203&vs_city=Austin&vs_state=Texas&vs_zip=12345&vs_birthday_month=December&vs_birthday_day=8&vs_birthday_year=1980&vs_country=United%20States%20of%20America&vs_code=1234

You will notice how all the fields are prefilled when visiting the above link.


We're here to help

If you have any further questions, please start a Chat. Just "Click" on the chat icon in the lower right corner to talk with our support team.

Did this answer your question?