Track Events
curl --request POST \
--url https://{environment}.userpilot.io/v1/track \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"user_id": "user_789456",
"event_name": "schedule_appointment",
"metadata": {
"appointment_date": "2024-02-01T10:00:00Z",
"appointment_type": "Initial Consultation",
"scheduled_by": "Sarah Johnson",
"specialty": "Cardiology",
"provider_id": "dr_smith_123",
"appointment_status": "confirmed"
}
}
'import requests
url = "https://{environment}.userpilot.io/v1/track"
payload = {
"user_id": "user_789456",
"event_name": "schedule_appointment",
"metadata": {
"appointment_date": "2024-02-01T10:00:00Z",
"appointment_type": "Initial Consultation",
"scheduled_by": "Sarah Johnson",
"specialty": "Cardiology",
"provider_id": "dr_smith_123",
"appointment_status": "confirmed"
}
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
user_id: 'user_789456',
event_name: 'schedule_appointment',
metadata: {
appointment_date: '2024-02-01T10:00:00Z',
appointment_type: 'Initial Consultation',
scheduled_by: 'Sarah Johnson',
specialty: 'Cardiology',
provider_id: 'dr_smith_123',
appointment_status: 'confirmed'
}
})
};
fetch('https://{environment}.userpilot.io/v1/track', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{environment}.userpilot.io/v1/track",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user_id' => 'user_789456',
'event_name' => 'schedule_appointment',
'metadata' => [
'appointment_date' => '2024-02-01T10:00:00Z',
'appointment_type' => 'Initial Consultation',
'scheduled_by' => 'Sarah Johnson',
'specialty' => 'Cardiology',
'provider_id' => 'dr_smith_123',
'appointment_status' => 'confirmed'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{environment}.userpilot.io/v1/track"
payload := strings.NewReader("{\n \"user_id\": \"user_789456\",\n \"event_name\": \"schedule_appointment\",\n \"metadata\": {\n \"appointment_date\": \"2024-02-01T10:00:00Z\",\n \"appointment_type\": \"Initial Consultation\",\n \"scheduled_by\": \"Sarah Johnson\",\n \"specialty\": \"Cardiology\",\n \"provider_id\": \"dr_smith_123\",\n \"appointment_status\": \"confirmed\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{environment}.userpilot.io/v1/track")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"user_id\": \"user_789456\",\n \"event_name\": \"schedule_appointment\",\n \"metadata\": {\n \"appointment_date\": \"2024-02-01T10:00:00Z\",\n \"appointment_type\": \"Initial Consultation\",\n \"scheduled_by\": \"Sarah Johnson\",\n \"specialty\": \"Cardiology\",\n \"provider_id\": \"dr_smith_123\",\n \"appointment_status\": \"confirmed\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{environment}.userpilot.io/v1/track")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_id\": \"user_789456\",\n \"event_name\": \"schedule_appointment\",\n \"metadata\": {\n \"appointment_date\": \"2024-02-01T10:00:00Z\",\n \"appointment_type\": \"Initial Consultation\",\n \"scheduled_by\": \"Sarah Johnson\",\n \"specialty\": \"Cardiology\",\n \"provider_id\": \"dr_smith_123\",\n \"appointment_status\": \"confirmed\"\n }\n}"
response = http.request(request)
puts response.read_body{
"errors": [
{
"details": "<string>",
"error": "<string>",
"error_code": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"details": "<string>",
"error": "<string>",
"error_code": "<string>",
"message": "<string>"
}
]
}Endpoints
Track Event
Record a custom event for a user with optional metadata properties via HTTP POST request.
POST
/
v1
/
track
Track Events
curl --request POST \
--url https://{environment}.userpilot.io/v1/track \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"user_id": "user_789456",
"event_name": "schedule_appointment",
"metadata": {
"appointment_date": "2024-02-01T10:00:00Z",
"appointment_type": "Initial Consultation",
"scheduled_by": "Sarah Johnson",
"specialty": "Cardiology",
"provider_id": "dr_smith_123",
"appointment_status": "confirmed"
}
}
'import requests
url = "https://{environment}.userpilot.io/v1/track"
payload = {
"user_id": "user_789456",
"event_name": "schedule_appointment",
"metadata": {
"appointment_date": "2024-02-01T10:00:00Z",
"appointment_type": "Initial Consultation",
"scheduled_by": "Sarah Johnson",
"specialty": "Cardiology",
"provider_id": "dr_smith_123",
"appointment_status": "confirmed"
}
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
user_id: 'user_789456',
event_name: 'schedule_appointment',
metadata: {
appointment_date: '2024-02-01T10:00:00Z',
appointment_type: 'Initial Consultation',
scheduled_by: 'Sarah Johnson',
specialty: 'Cardiology',
provider_id: 'dr_smith_123',
appointment_status: 'confirmed'
}
})
};
fetch('https://{environment}.userpilot.io/v1/track', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{environment}.userpilot.io/v1/track",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'user_id' => 'user_789456',
'event_name' => 'schedule_appointment',
'metadata' => [
'appointment_date' => '2024-02-01T10:00:00Z',
'appointment_type' => 'Initial Consultation',
'scheduled_by' => 'Sarah Johnson',
'specialty' => 'Cardiology',
'provider_id' => 'dr_smith_123',
'appointment_status' => 'confirmed'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{environment}.userpilot.io/v1/track"
payload := strings.NewReader("{\n \"user_id\": \"user_789456\",\n \"event_name\": \"schedule_appointment\",\n \"metadata\": {\n \"appointment_date\": \"2024-02-01T10:00:00Z\",\n \"appointment_type\": \"Initial Consultation\",\n \"scheduled_by\": \"Sarah Johnson\",\n \"specialty\": \"Cardiology\",\n \"provider_id\": \"dr_smith_123\",\n \"appointment_status\": \"confirmed\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{environment}.userpilot.io/v1/track")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"user_id\": \"user_789456\",\n \"event_name\": \"schedule_appointment\",\n \"metadata\": {\n \"appointment_date\": \"2024-02-01T10:00:00Z\",\n \"appointment_type\": \"Initial Consultation\",\n \"scheduled_by\": \"Sarah Johnson\",\n \"specialty\": \"Cardiology\",\n \"provider_id\": \"dr_smith_123\",\n \"appointment_status\": \"confirmed\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{environment}.userpilot.io/v1/track")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"user_id\": \"user_789456\",\n \"event_name\": \"schedule_appointment\",\n \"metadata\": {\n \"appointment_date\": \"2024-02-01T10:00:00Z\",\n \"appointment_type\": \"Initial Consultation\",\n \"scheduled_by\": \"Sarah Johnson\",\n \"specialty\": \"Cardiology\",\n \"provider_id\": \"dr_smith_123\",\n \"appointment_status\": \"confirmed\"\n }\n}"
response = http.request(request)
puts response.read_body{
"errors": [
{
"details": "<string>",
"error": "<string>",
"error_code": "<string>",
"message": "<string>"
}
]
}{
"errors": [
{
"details": "<string>",
"error": "<string>",
"error_code": "<string>",
"message": "<string>"
}
]
}Headers
API authentication token in the format: Token {{API_KEY}}
Obtain your API key from the Userpilot Environment Settings.
Body
application/json
The unique identifier for the user. This is the ID that Userpilot uses to identify the user.
Example:
"user_789456"
Name of the event being tracked. Use descriptive names like 'schedule_appointment', 'purchase_completed', etc.
Example:
"schedule_appointment"
Optional event metadata. You can add, remove, or modify any properties as needed for your use case.
Show child attributes
Show child attributes
Response
Accepted - Event tracking successful
Was this page helpful?
āI