This documentation will explain how to prefill fields in the ViralSweep form.

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

Overview 

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.

https://cdn.elev.io/file/uploads/NGPhhY4gCWUeC_gWLbU-FKQnR_YDhuujRWBGtiu0wA0/fFewFMC7A-QETkukzOL0j-h7aQG42ori9rFIwOUu1oM/Screen Shot 2018-05-02 at 7.17.52 AM-BBU.png


<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','john@smith.com');
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('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

Please note: This specific option only works on the ViralSweep link we provide, it will not work if you embed the campaign into your own website.

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:

vs_email=test@test.com
vs_first_name=Joe
vs_last_name=Smith
vs_phone=2223334444
vs_address=1234 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

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

For example, our direct link is:

To append all these fields we add:

&vs_first_name=Josh&vs_last_name=Smith&vs
_email=Josh@gmail.com&vs_phone=1234567899
&vs_address=123 my street&vs_address2=apt
 3&vs_city=Austin&vs_state=Texas&vs_zip=1
2345&vs_birthday_month=December&vs_birthd
ay_day=8&vs_birthday_year=1980&vs_country
=United States of America

Our final link looks like this:


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

We're here to help

Still have questions about prefilling fields Simply click the support or live chat icon to get in touch with us.