Set up tracking
Send product events and identity updates to Altertable with SDKs or direct HTTP requests. The same payload model writes to the built-in product_analytics catalog, so client, server, mobile, and batch sources can be analyzed together.
Goal
Choose an SDK, connect it with a Product Analytics API key, and send events and identity updates to the built-in product_analytics catalog.
Prerequisites
- Enable Product Analytics for the target environment.
- Copy a Product Analytics API key.
- Choose a client-side or server-side SDK based on where your application sends events.
Steps
1. Install an SDK
Choose the SDK for your application language:
Language | Install |
|---|---|
| TypeScript / JavaScript | npm install @altertable/altertable-js |
| React | npm install @altertable/altertable-js @altertable/altertable-react |
| Python | pip install altertable or poetry add altertable |
| Ruby | gem install altertable |
| Swift | Swift Package Manager |
| Kotlin / Android | Follow the JVM or Android Gradle setup for package coordinates and the current version. |
2. Initialize the client and send data
Use these examples as the starting point for your application code:
import { altertable } from '@altertable/altertable-js';// Initialize with your API keyaltertable.init('YOUR_API_KEY');// Track a user eventaltertable.track('checkout_completed', {revenue: 49.99,plan: 'pro',currency: 'USD',});// Identify a useraltertable.identify('user_abc123', {plan: 'pro',});
After initialization:
- Track events with event properties.
- Identify users and attach traits.
- Optionally alias related identities.
3. Choose client-side or server-side behavior
Use a client-side SDK for events from a browser or mobile application. Use a server-side SDK for events from backend services or jobs, and pass a stable distinct_id to associate each event with its user.
Automatic page capture, session management, consent helpers, and offline queuing vary by SDK. Check the repository for your SDK for the features available in your runtime.
4. Configure page, screen, and consent helpers
If your SDK provides page or screen helpers, configure them for the views you want to track:
// Disable auto-capture if you need manual controlaltertable.init('YOUR_API_KEY', { autoCapture: false });// Then track page views manuallyaltertable.page('https://example.com/products');
Where supported, use consent helpers to control whether the SDK sends data:
// JavaScript — initialize with consent pendingaltertable.init('YOUR_API_KEY', { trackingConsent: 'pending' });// Later, when the user grants consentaltertable.configure({ trackingConsent: 'granted' });
Verification
Send one event from your application, then query the raw events table:
SELECT *FROM product_analytics.main.eventsORDER BY timestamp DESCLIMIT 10;
Confirm that the event name, distinct ID, timestamp, and properties match the payload your application sent.
Troubleshooting
- No events appear: confirm that Product Analytics is enabled in the same environment as the API key.
- Requests are rejected: check the authentication methods and replace an incorrect or expired API key.
- Users remain anonymous: call
identifywhen a stable user ID becomes available, and passdistinct_idexplicitly from server-side SDKs. - Automatic page or screen events are missing: confirm that your SDK supports page or screen capture, then enable its helper.