This integration connects the "Sweepstakes 2025" form on your Webflow site to Klaviyo, automatically opting in subscribers with a custom profile property sweepstakes-2025: true.
Webflow Site ID: 678e895adc23a4aae8d5c61c
Form Name: Sweepstakes 2025
Form ID: wf-form-Sweepstakes-2025
Klaviyo Site ID: UX2UHq
You have two options for integrating Webflow with Klaviyo:
Use this method if you want a simple, immediate solution without setting up a server.
-
Add Klaviyo Snippet to Webflow
- Go to your Webflow project dashboard
- Navigate to Project Settings → Custom Code
- In the "Footer Code" section, add the Klaviyo tracking script:
<script type="text/javascript"> !function(){if(!window.klaviyo){window._klaviyoq=[];var e=window.klaviyo=function(e,t,n){_klaviyoq.push([e,t,n])};e.push=function(e){_klaviyoq.push(e)};e.track=function(e,t,n){_klaviyoq.push(["track",e,t,n])};e.identify=function(e){_klaviyoq.push(["identify",e])};var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src="https://static.klaviyo.com/onsite/js/klaviyo.js?company_id=UX2UHq";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n)}}(); </script>
-
Add the Integration Script
- In the same "Footer Code" section (or in the page-specific settings for the sweepstakes page), add the contents of
klaviyo-integration.js - Or, host
klaviyo-integration.json a CDN and include it:
<script src="https://your-cdn.com/klaviyo-integration.js"></script>
- In the same "Footer Code" section (or in the page-specific settings for the sweepstakes page), add the contents of
-
Publish Your Site
- Publish your Webflow site for the changes to take effect
- Requires JavaScript to be enabled in the browser
- Klaviyo's client-side API has rate limits
- Less reliable than server-side integration
This is the more robust and reliable method, recommended for production use.
-
Deploy the Webhook Handler
You need to deploy
server/klaviyo-webhook.jsto a serverless platform. Here are options:Option A: Vercel (Recommended)
# Install Vercel CLI npm i -g vercel # Create a vercel.json file cat > vercel.json << EOF { "functions": { "server/klaviyo-webhook.js": { "memory": 1024, "maxDuration": 10 } } } EOF # Deploy vercel
Option B: Netlify
Create a
netlify.tomlfile:[functions] directory = "server"
Then deploy via Netlify CLI or connect your Git repository.
Option C: AWS Lambda
- Create a new Lambda function
- Upload
server/klaviyo-webhook.js - Create an API Gateway trigger
- Use the endpoint URL
-
Get Your Klaviyo Private API Key
- Log in to Klaviyo
- Go to Settings → API Keys
- Create a new Private API Key with the following scopes:
Profiles: ReadProfiles: Write
- Copy the private key (starts with
pk_)
-
Update the Webhook Handler
In
server/klaviyo-webhook.js, replace:const KLAVIYO_PRIVATE_KEY = 'pk_YOUR_PRIVATE_KEY_HERE';
with your actual private key.
-
Configure Webflow Form Webhook
- In Webflow, go to your site settings
- Navigate to Forms tab
- Find the "Sweepstakes 2025" form
- Add a webhook URL (the URL of your deployed function)
- Example:
https://your-vercel-app.vercel.app/api/klaviyo-webhook
-
Test the Integration
- Submit a test entry through your form
- Check your Klaviyo dashboard to verify:
- A new profile was created or updated
- The email address matches
- The custom property
sweepstakes-2025is set totrue
When someone submits the Sweepstakes 2025 form, the following data is sent to Klaviyo:
- Email: Required field
- First Name: Extracted from the "Name" field
- Last Name: Extracted from the "Name" field
- Phone Number: Optional
- Zip Code: Optional
- Custom Property:
sweepstakes-2025: true - Marketing Consent: Automatically opted in for email/SMS marketing
To test the integration:
- Fill out the Sweepstakes 2025 form on your live site
- Check the browser console (F12) for any errors (client-side only)
- Log in to Klaviyo and search for the email you submitted
- Verify the profile has
sweepstakes-2025: truein the custom properties
- Form not submitting: Check browser console for JavaScript errors
- Data not appearing in Klaviyo: Verify the Klaviyo snippet is loaded and the Site ID is correct
- CORS errors: Client-side API may have restrictions; consider server-side integration
- Webhook not receiving data: Check Webflow's webhook logs
- Klaviyo API errors: Verify your Private API Key has the correct scopes
- Missing data: Check the webhook handler logs for the exact payload from Webflow
To connect to your Webflow site using the CLI:
# Install Webflow CLI (if not already installed)
npm install -g @webflow/cli
# Authenticate
webflow login
# Clone your site
webflow site clone 678e895adc23a4aae8d5c61cNote: The Webflow CLI is primarily for Webflow Apps and Designer Extensions. For form integrations, you'll need to use the Custom Code method or webhooks as described above.
- Never commit your Klaviyo Private API Key to version control
- Use environment variables for sensitive data:
const KLAVIYO_PRIVATE_KEY = process.env.KLAVIYO_PRIVATE_KEY;
- Validate webhook requests to ensure they're from Webflow (check origin, add a secret token, etc.)
- Choose your integration method (client-side or server-side)
- Get your Klaviyo Private API Key (for server-side)
- Deploy the webhook handler (for server-side) or add the script to Webflow (for client-side)
- Test the integration
- Monitor submissions in Klaviyo
If you encounter any issues:
- Check the browser console for errors (client-side)
- Check your serverless function logs (server-side)
- Verify your Klaviyo API credentials
- Ensure the form name/ID matches exactly