Use Liquid in Conversion JavaScript
Privy supports the use of Liquid variables in your custom conversion JavaScript (JS). These variables allow you to inject information related to a signup event, including contact and display information, into your custom JS code.
Supported variables
The following variables are supported in your conversion JS:
- {{contact.email}} — The email address of the contact who just signed up.
- {{contact.first_name}} — The first name of the contact who just signed up.
- {{contact.last_name}} — The last name of the contact who just signed up.
- {{signup.coupon_code}} — The coupon code that was shown to the contact who just signed up.
- {{campaign.id}} — The ID of the display associated with the contact's signup.
- {{contact.custom_fields.custom_name}} - The value associated with a custom field that was included in the display's form.
Variable requirements and limitations
The following requirements and limitations apply to custom fields:
- A custom field variable must exactly match the name of the field in the Privy form.
- The {{contact.custom_fields}} variable cannot be used; only individual fields are supported.
- The only contact data that will be available for Liquid variable rendering after a form is submitted is the data that was collected during the current signup event.
Include variables in your code
Liquid variables and their associated attribute values are included in your code by applying a specific format to the custom JavaScript snippet. Typical use cases include:
Print to console
If a user named "Joe Smith" with the email "joesmith@example.com" just signed up, the above code will print "Joe Smith (joesmith@example.com) just signed up!" to the console.
Redirect and pass a variable value
The above code will redirect the user after signing up and pass the display id as a URL parameter to the new page.