Auto-Enter User From Your Website’s Logged In User Session / Cookie Data
Plan required: Premium or higher.
You can pre-fill the name and email in the entry form for a user who is already logged in to your website, and optionally enter them into the giveaway automatically.
Example: a user is logged in to your website and has not entered your giveaway yet. Pull their name and email from your session data and pass them to the widget. If you also turn on auto-login, the user is entered with that name and email without filling in the form.
Embedded giveaway
Add three attributes to the sw_container div of your embed code.
Embed code without pre-fill:
<div id="29218-9c7ong3k" class="sw_container"><script type="text/javascript" src="https://sweepwidget.com/w/j/w_init.js?v=3"></script></div>
Attributes to add:
data-email-prefill="[email protected]"
data-name-prefill="John Doe"
data-auto-login-prefill="1"
Take the values from your session or cookie data. Set data-auto-login-prefill to 1 to log the user in automatically, or 0 to only pre-fill the form.
Example in PHP (escape the values, they come from your own user data):
<div id="29218-9c7ong3k" class="sw_container"
data-name-prefill="<?php echo htmlspecialchars($user['name'], ENT_QUOTES); ?>"
data-email-prefill="<?php echo htmlspecialchars($user['email'], ENT_QUOTES); ?>"
data-auto-login-prefill="1"><script type="text/javascript" src="https://sweepwidget.com/w/j/w_init.js?v=3"></script></div>
Names and emails are passed to the giveaway in its web address. If a value can contain characters such as & or +, URL-encode it before you print it.
Hosted landing page
Pass the same information as parameters in the page address:
data-namedata-emaildata-auto-login(1for yes,0for no)
Example link:
https://sweepwidget.com/c/438-tu2zjsh4?data-name=Steven&[email protected]&data-auto-login=0