Last updated
The Klaviyo integration adds each customer’s referral code to their Klaviyo profile. It also records a Referral Code Created event, which you can use to start a flow. It doesn’t change anyone’s email consent.
Before you start: you need a Klaviyo account and permission to create API keys in it.
1. Create a Klaviyo API key
- In Klaviyo, go to Settings → API keys.
- Click Create Private API Key and name it, for example “Refer a Friend”.
- Choose Custom Key and give it Profiles: Read/Write and Events: Write. A full-access key also works.
- Click Create and copy the key. Klaviyo shows it only once.
2. Connect the plugin
- Go to WooCommerce → Refer a Friend → Integrations.
- Under Klaviyo, turn on Enable Integration.
- Paste the key into Klaviyo Private API Key.
- Click Save Settings.
- To send codes your customers already have, go to WooCommerce → Status → Tools and click Sync to integrations.
What’s sent to Klaviyo
Each time a referral code is created, the plugin creates or updates the customer’s profile:
| Profile field | Contents |
|---|---|
| The customer’s email. | |
| First name, Last name | When known. |
referral_code |
The customer’s referral code. |
referral_created_date |
When it was sent. |
It then records a Referral Code Created event with referral_code, user_type (registered_user or guest_user) and created_at.
Use the code in Klaviyo emails
Build the referral link from your landing page and the code, for example:
https://yourstore.com/?raf={{ person.referral_code }}
To send it automatically to new advocates:
- In Klaviyo, go to Flows → Create Flow → Build your own.
- Choose Referral Code Created as the trigger.
- Add an email that includes the link above. In flows started by this event you can also use
{{ event.referral_code }}. - To send guests different text, add a split on
user_type. - Turn the flow on.
Check it worked
Create a test customer account, then search for that email in Klaviyo Profiles. The profile should have a referral_code property, and its activity should show Referral Code Created.
If nothing arrives, check that the key has the scopes above. Klaviyo errors are written to your PHP error log, starting with “Klaviyo API Error”.
If you used the old Klaviyo code snippet from this page, remove it. Otherwise each code is sent twice.