Klaviyo Multi-Environment Guide
How to manage Klaviyo across Dev, Staging, and Production environments.
Overview
We use separate Klaviyo accounts for testing vs production to avoid polluting real customer data.
| Environment | Klaviyo Account | Purpose |
|---|---|---|
| Dev | eli-health-test | API development, debugging |
| Staging | eli-health-test | QA testing, flow verification |
| Production | eli-health | Real customers |
Part 1: Developer Setup
Klaviyo Account Setup
Ask Morgane to create:
- A new Klaviyo account called
eli-health-test(free tier is fine) - Add developers as users so they can view test profiles
Environment Variables
Location: eli-devops/tf/ and Secret Manager
Terraform Configuration:
# dev.tfvars
klaviyo_api_key = "pk_test_xxx"
# staging.tfvars
klaviyo_api_key = "pk_test_xxx"
# production.tfvars
klaviyo_api_key = "pk_prod_xxx"
Secret Manager Setup:
# Create secrets (one-time)
echo -n "pk_test_xxx" | gcloud secrets create klaviyo-api-key-dev --data-file=-
echo -n "pk_test_xxx" | gcloud secrets create klaviyo-api-key-staging --data-file=-
echo -n "pk_prod_xxx" | gcloud secrets create klaviyo-api-key-prod --data-file=-
Backend Configuration
File: eli-backend-api/src/modules/klaviyo/klaviyo.service.ts
KLAVIYO_API_KEY → From environment/Secret Manager
KLAVIYO_ENABLED → Optional flag to disable entirely
Testing Checklist (Dev)
Before merging:
- API call succeeds (no auth errors)
- Profile created in test Klaviyo
- Properties populated correctly
- Errors logged but don't block test completion
Testing Checklist (Staging)
Before production deploy:
- Complete a real test in staging app
- Profile appears in test Klaviyo with correct email
-
total_tests_completedincrements -
test_stock_percentagecalculates correctly -
first_test_completedanddays_to_first_testset on first test - Automation flow triggers (if cloned to test account)
Part 2: Marketing Setup (Morgane)
Account Structure
| Account | URL | Purpose |
|---|---|---|
| eli-health-test | klaviyo.com (separate login) | Build and test flows |
| eli-health | klaviyo.com | Production - real customers |
Workflow: Build → Test → Deploy
How to Clone Flows to Production
Step-by-step:
- In Test Account: Go to Flows
- Find your flow: Click the ⋮ (three dots) menu
- Select "Clone"
- Choose "Clone to multiple accounts"
- Search for "eli-health" (production account)
- Name the flow (e.g., same name or add version)
- Review settings:
- Adjust segments if test vs prod segments differ
- Verify trigger metrics exist in production
- Click Clone - wait a few minutes
- In Production Account:
- Find the cloned flow
- Review all steps
- Activate when ready
What Gets Cloned
| Cloned | Not Cloned |
|---|---|
| Flow structure | Specific profiles |
| Email templates | Analytics/metrics |
| Trigger logic | Live status (starts as Draft) |
| Timing delays | Account-specific lists |
| Conditional splits | - |
Updating Production Flows
Option A: Edit in Place
- Make changes directly in production
- Good for small tweaks (copy, timing)
Option B: Clone Again
- Make changes in test account
- Re-clone to production
- Deactivate old flow, activate new one
- Good for major changes
Tips for Morgane
- Name flows consistently across accounts (e.g., "First Test Welcome - v2")
- Test with your own email in the test account before cloning
- Use Klaviyo's Preview feature to see how emails render
- Check segments exist in production before cloning segment-triggered flows
- Keep test account clean - archive old test flows
Quick Reference
Developer Commands
# Check which Klaviyo key is configured
gcloud secrets versions access latest --secret=klaviyo-api-key-dev
# View logs for Klaviyo calls
gcloud logging read "resource.type=cloud_run_revision AND textPayload:klaviyo" --limit=20
Klaviyo URLs
| Account | Dashboard |
|---|---|
| Test | https://www.klaviyo.com/dashboard (eli-health-test login) |
| Production | https://www.klaviyo.com/dashboard (eli-health login) |
API Documentation
Related Documents
- Klaviyo Integration Guide - Business requirements
- Klaviyo Implementation Details - Technical architecture
Document History
| Date | Author | Changes |
|---|---|---|
| 2025-01-26 | Chip | Initial multi-environment guide |