Track
Track is a function that allows you to track events in your application.Track
The track function allows you to track events in your application. It takes two arguments: the event name and an optional object of properties.
Server
If you plan to track events in your server-side application, you can use the following code to send a POST request to the API.
curl -X POST https://api.openpanel.dev/track \
-H "Content-Type: application/json" \
-H "openpanel-client-id: YOUR_CLIENT_ID" \
-H "openpanel-client-secret: YOUR_CLIENT_SECRET" \
-d '{
"type": "track",
"payload": {
"name": "my_event",
"properties": {
"foo": "bar"
}
}
}'
Client
If you're using the client SDK, you can use the track function to track events in your application.
track('your_event_name', {
foo: 'bar',
baz: 'qux',
// reserved property name
__identify: {
profileId: 'your_user_id', // required
email: 'your_user_email',
firstName: 'your_user_name',
lastName: 'your_user_name',
avatar: 'your_user_avatar',
}
});