Skip to content

About

Altertable's Product Analytics Python API Client

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

2 watching

Forks

Repository files navigation

Altertable Python SDK

Official Python SDK for Altertable Product Analytics.

Installation

You can install the package via pip:

pip install altertable

Or using poetry:

poetry add altertable

Usage

Initialization

from altertable import Altertable

client = Altertable("your_api_key")

Tracking Events

client.track(
    event="button_clicked",
    distinct_id="user_123",
    options={
        "properties": {
            "button_id": "signup_btn",
            "page": "home"
        }
    }
)

Batch tracking

Server applications can submit a caller-managed batch directly. The SDK does not impose a client-side batch-size limit.

client.track([
    {"event": "button_clicked", "distinct_id": "user_123"},
    {"event": "checkout_started", "distinct_id": "user_123"},
])

Pass arrays to identify and alias for the same pass-through behavior.

Environment

The API key selects the Product Analytics environment. The environment argument is deprecated and ignored, and environment fields in options and batches are never sent. Replace unbound legacy API keys with environment-bound keys before upgrading.

Audience measurement

With an environment-bound API key, pass mode="audience" to send events without identity or environment fields:

audience = Altertable("your_api_key", mode="audience")
audience.track("docs_opened", options={"properties": {"page": "install"}})

Mode is fixed for each client. Audience events contain only mode, event, timestamp, and properties, including in batches; identify() and alias() return None without sending a request. Product clients drop any top-level mode field from batch entries.

Identifying Users

client.identify(
    distinct_id="user_123",
    options={
        "traits": {
            "email": "user@example.com",
            "name": "John Doe"
        },
        "anonymous_id": "previous_anon_id"
    }
)

Alias

client.alias(
    distinct_id="previous_anonymous_id",
    new_user_id="new_user_id"
)

License

The package is available as open source under the terms of the MIT License.

About

Altertable's Product Analytics Python API Client

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages