Sending Emails
Send transactional emails to customers.
Updated
On this page
Overview
DashForDevs integrates with email marketing providers like Klaviyo to send transactional and marketing emails. The SDK provides methods to identify subscribers and track events.
Initialize Email Marketing
import dash from "@/lib/dash"
const { active, provider } = await dash.marketing.init()
// active: true if email provider is configured
// provider: "klaviyo" | null
Identify Subscribers
await dash.email.identify({
email: "customer@example.com",
first_name: "Jane",
last_name: "Doe",
phone: "555-0123",
properties: {
source: "checkout",
lifetime_value: "250.00",
},
})
Track Events
await dash.email.track({
email: "customer@example.com",
event: "viewed_product",
properties: {
product_name: "Blue Dream",
product_price: "29.99",
product_url: "https://store.com/products/blue-dream",
},
})
Common Events to Track
| Event | When |
|---|---|
viewed_product | Customer views a product page |
added_to_cart | Item added to cart |
started_checkout | Checkout process began |
placed_order | Order completed |
subscribed | Customer opted into marketing |
REST API
# Get email config
GET /storefront/email/config
X-API-Key: pk_live_your_key
# Identify subscriber
POST /storefront/email/identify
Content-Type: application/json
{ "email": "customer@example.com", "properties": {} }
# Track event
POST /storefront/email/track
Content-Type: application/json
{ "event": "viewed_product", "properties": {} }
Next Steps
- Email Templates — Customizing email templates
- Contact Forms — Handling contact form emails
- Storefront Views — Page view tracking
Campaigns and automated sends on top of these are covered in email marketing.