Skip to content
DocumentationProduct Analytics
Product Analytics
Set up tracking

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.

Set up with your coding agent

Open this prompt in your coding agent from your application repository. It will inspect your stack and guide the implementation.

Agent prompt
Set up Altertable Product Analytics in this repository. Read https://altertable.ai/docs/product-analytics/setup.md and the linked official SDK documentation first. Inspect my framework, runtime, package manager, authentication, and existing analytics. Choose the matching SDK. Ask which user journey I want to measure and propose a small event plan before changing code. Guide me through enabling Product Analytics and configuring its environment-specific API key without committing secrets. MCP and lakehouse credentials do not replace this key. Reuse or initialize one shared client. Track completed actions, identify signed-in users, reset identity at sign-out, and respect consent. Check which helpers the SDK supports and avoid sensitive properties. Run checks. Send one named verification event with a unique test identity in the chosen environment. Query product_analytics.main.events by that event name and identity, and confirm the properties and timestamp. Do not use the newest row as proof. Use my Altertable connection if available. Summarize changed files, verification results, and remaining setup.

Prefer to configure it yourself? Follow the steps below.

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:

npm install @altertable/altertable-js

For Swift, add the package declaration to Package.swift dependencies and link the Altertable product to your target. For Kotlin, add the JVM dependency to build.gradle.kts; Android projects use the Android dependency. Use Maven Central in your Gradle repositories. See the SDK repositories for platform requirements.

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 key
altertable.init('YOUR_API_KEY');
​
// Track a user event
altertable.track('checkout_completed', {
revenue: 49.99,
plan: 'pro',
currency: 'USD',
});
​
// Identify a user
altertable.identify('user_abc123', {
plan: 'pro',
});

After initialization:

  1. Track events with event properties.
  2. Identify users and attach traits.
  3. 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.

If your SDK provides page or screen helpers, configure them for the views you want to track:

// Disable auto-capture if you need manual control
altertable.init('YOUR_API_KEY', { autoCapture: false });
​
// Then track page views manually
altertable.page('https://example.com/products');

Where supported, use consent helpers to control whether the SDK sends data:

// JavaScript — initialize with consent pending
altertable.init('YOUR_API_KEY', { trackingConsent: 'pending' });
​
// Later, when the user grants consent
altertable.configure({ trackingConsent: 'granted' });

Verification

Send a verification event named docs_verification with a unique test identity. Replace docs_test_<unique-id> below with the identity you sent. Use a new identity for each run:

SQL
SELECT *
FROM product_analytics.main.events
WHERE event = 'docs_verification'
AND distinct_id = 'docs_test_<unique-id>'
ORDER BY timestamp DESC
LIMIT 10;

Confirm that the event name, distinct ID, timestamp, and properties match the payload your application sent. A different recent event does not prove this test succeeded. Allow for ingestion delay and retry the same filtered query before sending another event.

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 identify when a stable user ID becomes available, and pass distinct_id explicitly from server-side SDKs.
  • Automatic page or screen events are missing: confirm that your SDK supports page or screen capture, then enable its helper.

Next steps