This documentation will explain how to prefill fields in the ViralSweep form.
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.
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.
//change widget to full or lightbox depending on which style you are using
vs_prefill_field('address','23 Main St');
vs_prefill_field('country','United States of America');
vs_prefill_field('18940_1525208752','This is a custom field example-don't copy.');
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_address=1234 my street
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_address=123 my street&vs_address2=apt
=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.