Server SDKs

Custom Event

Send custom events with the Python SDK

Track game- or app-specific actions that are not covered by the built-in event types by sending a custom event via the webhook endpoint.

Usage

from audiencelab_python_sdk import (
    Client, UserData, CustomEventData, AppEvent
)

client = Client(
    api_key="YOUR_API_KEY",
    base_url="https://analytics.geeklab.app"
)

user_data = UserData()
user_data.set_user_id("user_12345")
user_data.set_user_ip("203.0.113.42")
user_data.set_user_creative_token_info({
    "creative_token": "abc123-creative-token",
    "os_system": "iOS 17.4",
    "device_name": "iPhone 14 Pro",
    "device_model": "iPhone15,2",
})

custom = CustomEventData()
custom.set_event_name("level_complete")
custom.set_properties({
    "level": 10,
    "difficulty": "hard",
    "duration_seconds": 213,
})

response = AppEvent(client, custom, user_data).send()

CustomEventData Fields

Prop

Type

User context is added automatically

You do not include user_id, IP, device info, or session context in the event payload. AppEvent reads them from the UserData object. Initialize a UserData per user (set_user_id, set_user_ip), hydrate it with set_user_creative_token_info(...) using the Register User or Fetch Token response, then send that user's events with it.

Response

200 OK:

{ "message": "Webhook Received" }