When to Use Backend APIs
Perfect for server-side tracking:
- User registration and authentication events
- Subscription and payment processing
- Admin actions and system events
- Webhook processing
- Background job events
- Any event that doesn’t depend on the user’s browser
Key benefits:
- ✅ Most reliable - no client-side dependencies
- ✅ Secure - API keys never exposed to browsers
- ✅ Server context - automatic IP, user agent detection
- ✅ Works with any backend language
Quick Setup (5 minutes)
Get your API key
- Sign up at userboo.st
- Go to Settings → API Keys
- Copy your Server-side API key (starts with
ub_live_)
Choose your integration method
Pick the approach that fits your stack:Recommended for Node.js applicationsnpm install @userboost/sdk
import { UserBoost } from "@userboost/sdk";
UserBoost.init({
apiKey: process.env.USERBOOST_API_KEY,
debug: process.env.NODE_ENV === "development",
});
Universal approach for any languagecurl -X POST https://api.userboo.st/v1/event \
-H "Authorization: Bearer ub_live_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"event": "user_signed_up",
"user": {
"id": "user_123",
"email": "[email protected]"
}
}'
Track your first event
// Track user registration
UserBoost.event("user_signed_up", {
user: {
id: "user_123",
email: "[email protected]",
traits: {
plan: "free",
signup_method: "email"
}
}
});
// Track feature usage
UserBoost.event("feature_used", {
user: { id: "user_123" },
properties: {
feature: "dashboard",
usage_count: 1
}
});
# User registration event
curl -X POST https://api.userboo.st/v1/event \
-H "Authorization: Bearer $USERBOOST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"event": "user_signed_up",
"user": {
"id": "user_123",
"email": "[email protected]",
"traits": {
"plan": "free",
"signup_method": "email"
}
}
}'
# Feature usage event
curl -X POST https://api.userboo.st/v1/event \
-H "Authorization: Bearer $USERBOOST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"event": "feature_used",
"user": { "id": "user_123" },
"properties": {
"feature": "dashboard",
"usage_count": 1
}
}'
Verify it's working
- Go to your UserBoost dashboard
- Navigate to Events → Live Stream
- Your test event should appear within 30 seconds
Enable debug mode during development to see detailed logs in your console.
Language Examples
UserBoost works with any language that can make HTTP requests. Here are quick examples:
Node.js
Python
Go
PHP
Ruby
// Using the official SDK (recommended)
import { UserBoost } from "@userboost/sdk";
UserBoost.init({
apiKey: process.env.USERBOOST_API_KEY
});
// Track events anywhere in your app
UserBoost.event("user_signed_up", {
user: {
id: user.id,
email: user.email,
traits: { plan: user.plan }
}
});
import requests
import os
def track_event(event, user_id, **properties):
url = "https://api.userboo.st/v1/event"
headers = {
"Authorization": f"Bearer {os.environ['USERBOOST_API_KEY']}",
"Content-Type": "application/json"
}
data = {
"event": event,
"user": {"id": user_id},
"properties": properties
}
response = requests.post(url, json=data, headers=headers)
return response.status_code == 200
# Usage
track_event("user_signed_up", "user_123", plan="free")
package main
import (
"bytes"
"encoding/json"
"net/http"
"os"
)
type Event struct {
Event string `json:"event"`
User map[string]interface{} `json:"user"`
Properties map[string]interface{} `json:"properties,omitempty"`
}
func TrackEvent(event string, userID string, properties map[string]interface{}) error {
eventData := Event{
Event: event,
User: map[string]interface{}{"id": userID},
Properties: properties,
}
jsonData, _ := json.Marshal(eventData)
req, _ := http.NewRequest("POST", "https://api.userboo.st/v1/event", bytes.NewBuffer(jsonData))
req.Header.Set("Authorization", "Bearer "+os.Getenv("USERBOOST_API_KEY"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
return nil
}
// Usage
TrackEvent("user_signed_up", "user_123", map[string]interface{}{
"plan": "free",
})
<?php
function trackEvent($event, $userId, $properties = []) {
$url = 'https://api.userboo.st/v1/event';
$apiKey = $_ENV['USERBOOST_API_KEY'];
$data = [
'event' => $event,
'user' => ['id' => $userId],
'properties' => $properties
];
$options = [
'http' => [
'header' => [
"Authorization: Bearer $apiKey",
"Content-Type: application/json"
],
'method' => 'POST',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
return $result !== false;
}
// Usage
trackEvent('user_signed_up', 'user_123', ['plan' => 'free']);
?>
require 'net/http'
require 'json'
def track_event(event, user_id, properties = {})
uri = URI('https://api.userboo.st/v1/event')
data = {
event: event,
user: { id: user_id },
properties: properties
}
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{ENV['USERBOOST_API_KEY']}"
request['Content-Type'] = 'application/json'
request.body = data.to_json
response = http.request(request)
response.code == '200'
end
# Usage
track_event('user_signed_up', 'user_123', { plan: 'free' })
Common Event Patterns
Track these key events to build effective user journey funnels:
Authentication Events
// User registration
UserBoost.event("user_signed_up", {
user: {
id: user.id,
email: user.email,
traits: {
plan: "free",
signup_method: "email",
referral_source: req.headers.referer
}
}
});
// Login events
UserBoost.event("user_logged_in", {
user: { id: user.id },
properties: {
login_method: "password",
ip_address: req.ip
}
});
Onboarding Milestones
// Profile completion
UserBoost.event("profile_completed", {
user: { id: user.id },
properties: {
completion_percentage: 100,
time_to_complete: "2 minutes"
}
});
// First key action
UserBoost.event("first_project_created", {
user: { id: user.id },
properties: {
project_type: "web_app",
days_since_signup: 1
}
});
Subscription Events
// Subscription changes
UserBoost.event("subscription_upgraded", {
user: { id: user.id },
properties: {
from_plan: "free",
to_plan: "pro",
annual: true,
amount: 99
}
});
Environment Setup
Store your API key securely using environment variables:
USERBOOST_API_KEY=ub_live_your_api_key_here
Never commit API keys to version control. Always use environment variables and add .env files to your .gitignore.
Testing & Debugging
Enable Debug Mode (Node.js SDK)
UserBoost.init({
apiKey: process.env.USERBOOST_API_KEY,
debug: true, // Enables detailed console logging
});
Test Event
// Send a test event to verify setup
UserBoost.event("integration_test", {
user: { id: "test_user_" + Date.now() },
properties: {
test: true,
timestamp: new Date().toISOString()
}
});
Common Issues
Events not appearing in dashboard
Check these common causes:
- API key format (must start with
ub_live_)
- Required
user.id field is missing
- Network connectivity issues
- Wrong environment (test vs live keys)
Enable debug mode to see detailed error messages.
- Verify your API key is correct
- Ensure you’re using a server-side API key (not browser key)
- Check that the key starts with
ub_live_
- Ensure your server can reach
api.userboo.st
- Check firewall settings
- Verify SSL/TLS configuration
What’s Next?
Your backend integration is now ready! UserBoost will automatically start tracking your server-side events and building user journey funnels.