Skip to main content

Prefill Fields

Written by Aldin Rey
Updated over 3 weeks ago

Prefilling fields lets you automatically pass user data into your ViralSweep form—so users don’t have to enter it themselves.

This is especially useful when directing users to a campaign after they’ve:

  • Logged into your site

  • Completed another form

  • Already shared their information elsewhere

👉 Looking for something specific?


Implementation options

There are two ways to prefill fields in ViralSweep:

Option 1: JavaScript implementation

Use JavaScript to dynamically prefill form fields on page load.

How it works:

  1. Add the script below before your campaign embed script (widget, full page, or lightbox)

  2. Update the field values with your user’s data

<script>
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','Custom field value');
}
</script>

Using custom fields

  • Add the custom field to your form first

  • Use your browser’s Inspect tool to find the field ID

  • Replace the example ID (18940_1525208752) with your own

If you need help finding a field ID, contact support.


Option 2: URL parameters

You can also prefill fields by adding parameters to your campaign URL.

Supported parameters include:

  • vs_email

  • vs_first_name

  • vs_last_name

  • vs_phone

  • vs_address, vs_address2, vs_city, vs_state, vs_zip, vs_country

  • vs_birthday_month, vs_birthday_day, vs_birthday_year

  • vs_code

Example:

Base campaign URL:

https://app.viralsweep.com/vrlswp/full/d7f01f-70537?framed=1

With prefilled fields:

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

When users visit this link, the form will automatically be prefilled.


Important notes

  • Field values must match ViralSweep’s expected format

    • Example: Use “United States of America” (not “USA”)

  • Replace static values with dynamic user data when possible

  • URL parameters must be properly encoded (e.g., spaces become %20)


Need help?

If you have any questions, our support team is here to help.

Click the chat icon in the lower-right corner to start a conversation.

Did this answer your question?