How to track events
updated 1 year ago
In this article:
Engage lets you track user events in different ways. You can use the User API or any of the available SDKs. You can also use any of our Integrations to send events from services you already use. For example, if you already use Segment or PostHog for your event tracking, events from these integrations are automatically sent to Engage. If you use Stripe, billing events for your users will be automatically sent to Engage.
You can track events using more than one of these methods. The best integrations we have seen use a combination of the methods. For example, you can use the Flutter SDK to track events on mobile, the API (or another SDK) to track events on your backend server, and an integration like Stripe to get billing events.
Events have different forms. Here are the supported forms and how you can track them in Engage with examples using the API and some SDKs. For more details, see the User API or your choice SDK.
Tracking an event with value
Some events have value. Examples:
Paid (the event) -> $20 (the value)
Plan upgraded -> Pro
Teammate added -> Bruce Wayne
Engage allows you to track these types of events by sending both the event name and value via the API or SDK.
POST https://api.engage.so/v1/users/{userid}/events
{
"event": "Paid",
"value": 49.99
}
Using the Javascript SDK:
// const Engage = require('@engage_so/js')
// Engage.init('api_key')
Engage.track('userid', {
event: 'New badge',
value: 'gold'
})
Tracking an event with properties
Some events have multiple properties and not just a single value. You can track these events by sending the event name and properties to Engage.
Example:
Product added (the event)
id (property name) -> abc123 (property value)
color -> red
type -> T-shirt
size -> M
Another example
Transfer completed
amount -> 65.12
recipient_id -> 123xyz
POST https://api.engage.so/v1/users/{userid}/events
{
"event": "Transfer completed",
"properties": {
"amount": 65.12,
"recipient_id": "123xyz"
}
}
Using the PHP SDK:
$engage->users->track($userId, [
'event' => 'Add to cart',
'properties' => [
'product' => 'T123',
'currency' => 'USD',
'amount' => 12.99
]
]);
Tracking an event by name only
Some events do not have or need values or properties. Engage lets you track these types of events by sending only the event name. Examples:
Completed KYC
Verified email
Using the API:
POST https://api.engage.so/v1/users/{userid}/events
{
"event": "Completed KYC"
}
Was this article helpful?