54 lines
1.0 KiB
Plaintext
54 lines
1.0 KiB
Plaintext
---
|
|
title: Events
|
|
description: Track actions and trigger workflows
|
|
icon: Activity
|
|
---
|
|
|
|
## Overview
|
|
|
|
Events track user actions. Use them to trigger workflows and update contact data.
|
|
|
|
## Tracking
|
|
|
|
```javascript
|
|
await fetch('/v1/track', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Authorization': 'Bearer pk_your_public_key'
|
|
},
|
|
body: JSON.stringify({
|
|
event: 'signed_up',
|
|
email: user.email,
|
|
data: { plan: 'pro' }
|
|
})
|
|
});
|
|
```
|
|
|
|
Creates/updates contact and records the event.
|
|
|
|
## Keys
|
|
|
|
- **Public key (pk_*):** Safe for client-side, only works with `/v1/track`
|
|
- **Secret key (sk_*):** Server-side only, full API access
|
|
|
|
## Event data
|
|
|
|
**Persistent (default):** Saved to contact
|
|
```javascript
|
|
data: { plan: 'premium' }
|
|
```
|
|
|
|
**Non-persistent:** Available only to workflow
|
|
```javascript
|
|
data: {
|
|
orderId: { value: 'order-123', persistent: false }
|
|
}
|
|
```
|
|
|
|
## Automatic events
|
|
|
|
Plunk tracks these automatically:
|
|
- `email.sent`, `email.opened`, `email.clicked`
|
|
- `email.bounced`, `email.complained`
|
|
- `segment.entered`, `segment.exited`
|