How to set custom variable value for user when they submit the Prefinery form

Custom variables can be set using our API (i.e. when you create or update a user), but if you're simply looking for a way to set custom variable to the user that just signed up through the Prefinery form, you can use the Javascript Fetch API with our Instant Signup Link feature

For example, in your form's Conversion Tracking Code box, you could add the following script so it runs on form submit: 

<script>fetch('https://i.prefinery.com/projects/PROJECT_UID/users/instant?email=${encodeURIComponent(prefinery_data.user.email)}&custom_var1=CUSTOM_VARIABLE_VALUE', { mode: 'no-cors'});</script>

Where  PROJECT_UID is your project's UID which can be found in your account by clicking the Settings menu and then choosing Project Settings > General Settings, and CUSTOM_VARIABLE_VALUE is the value you want to set for the custom_var1 (you can set one or more custom variables per user, up to custom_var3) variable. 

This method works by resubmitting the user's email address along with the custom variable value through the instant signup link immediately after they signup. 

What are custom variables used for?

Prefinery allows you to set up to 3 custom variables for each user to hold any data strings, usually used internally on your end, to attach to the user. 

Custom variables can be used to - besides the standard variables (e.g. user-collected information through your form) - segment/filter users, insert them as dynamic content in emails, or simply to store any information you want to associate with the user. 

They can also be used to modify email behavior by utilizing them as a delivery condition. For example, if you want to send a specific email copy to all users with the "alumni" value for their Custom Variable 1 you'd set your email message's delivery condition like as follows: 

Still need help? How can we help? How can we help?