SDKs
Altertable Product Analytics SDKs follow the same mental model across languages:
- Initialize a client with your API key.
- Track events with event properties.
- Identify users and attach traits.
- (Optional) Alias anonymous and known identities.
Quick Start by Language
Language | Install | Repository |
|---|---|---|
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 | JVM: implementation("ai.altertable.sdk:altertable-kotlin:0.1.0"); Android apps also add implementation("ai.altertable.sdk:altertable-android:0.1.0") |
Client-Side vs Server-Side SDKs
SDKs fall into two categories with different capabilities:
Capability | Client-side | Server-side |
|---|---|---|
Event tracking | Yes | Yes |
User identification | Yes | Yes |
Aliasing | Yes | Yes |
Automatic page/screen tracking | Yes | No |
Session & device ID management | Automatic | You pass distinct_id on each call |
Tracking consent | Built-in | Manage externally |
Event queuing & offline support | Yes | No |
Page and Screen Tracking
Client-side SDKs auto-capture navigation events by default. The mechanism varies by platform:
- JavaScript / React: Listens for
popstateandhashchangebrowser events. Disable withautoCapture: falseduring init, then callaltertable.page(url)manually. - Kotlin / Android: Auto-tracks Activity screen views when
captureScreenViewsis enabled (default). In Compose, use the.screenView(name:)modifier orTrackScreenViewcomposable. - Swift / iOS: Auto-tracks UIKit view controller appearances when
captureScreenViewsis enabled (default). In SwiftUI, use the.screenView(name:)view modifier.
Server-side SDKs don't track pages or screens—include page context in event properties when needed.
Tracking Consent
Client-side SDKs include built-in consent management for privacy compliance. Events are queued while consent is pending and flushed automatically when consent is granted. If consent is denied, queued events are dropped.
State | Behavior |
|---|---|
granted | Events are sent immediately. |
denied | Events are dropped. Queue is cleared. |
pending | Events are queued until consent changes. |
dismissed | Events are queued (same as pending). |
Set consent during initialization or update it at runtime:
// JavaScript — initialize with consent pendingaltertable.init('YOUR_API_KEY', { trackingConsent: 'pending' });// Later, when the user grants consentaltertable.configure({ trackingConsent: 'granted' });
Server-side SDKs don't manage consent—handle it in your application before sending events.
Cross-Language API Concepts
- Initialization: Each SDK initializes with a project API key plus optional runtime configuration.
- Tracking: Track an event name with structured properties.
- Identity: Associate traits with a known user identifier (
identify). - Alias: Link an anonymous/pre-login identity to a known user identity.
- Consent and privacy: Consent controls are available in client-side SDKs—exact config names differ by language.
Next Steps
- Authentication: Get your API key and authenticate your SDKs
- Track Events: Learn how to track product events
- Identify Users: Set up user identification