Skip to main content

Python SDK for AudienceLab services

Project description

AudienceLab Python SDK

With the introduction of Apple's App Tracking Transparency (ATT) framework, mobile advertisers have faced significant challenges in measuring ad performance on iOS. This challenge is set to expand further with Google's upcoming Privacy Sandbox, reducing visibility into user-level attribution.

Geeklab is dedicated to developing a privacy-first marketing performance analytics platform that enables advertisers to gain actionable insights while adhering to evolving data privacy regulations. Our solution aggregates performance data at the device/developer server level and provides creative-level analytics, ensuring that advertisers can optimize campaigns without relying on user-level tracking.

Overview

The AudienceLab NodeJS SDK is a lightweight client library for integrating with the AudienceLab API. It simplifies:

  • User registration and creative token fetching
  • Sending in-app events (purchases, ad views, retention events)
  • Collecting and managing device and user information

Installation

pip install audiencelab-python-sdk

Basic Usage

1. Initialize the Client and Construct User Data

First, import the necessary classes from the SDK. Create a client instance using your API key and base URL, and then build the user data object.

Note: Detailed device information is only required during the initial user registration. For all subsequent events, simply provide the user ID and IP address. If the event did not occur in real time, be sure to include the event timestamp (ISO 8601).

from audiencelab_python_sdk import Client, UserData, RegisterUser, FetchToken, RetentionData, PurchaseData, AdData, AppEvent

api_key = "your_api_key"
base_url = "https://example.com"
client = Client(api_key, base_url)

user_data = UserData() \
    .set_user_id("user_12345") \
    .set_user_ip("123.123.1.1") \
    .set_event_timestamp("2024-10-05T16:48:00+02:00") \
    .set_device_info({
        "device_name": "My Device",
        "height": 2436,
        "width": 1125,
        "os": "iOS",
        "os_version": "14.4",
        "device_model": "iPhone15,4",
        "timezone": "America/New_York"
    })

2.1 Register a User

Register a new user; Call this only once when a new user first downloads and opens the app.

This event will also return creative token information which updates your user data with the creative token information. In this case, step 2.2 is not required.

register_event = RegisterUser(client, user_data)
try:
    response = register_event.send()
    user_data.set_user_creative_token_info(response)
    print("User registered & creative token information set.")
except Exception as e:
    print("Error during user registration:", e)

2.2 Fetch the Creative Token

Creative token information fetching; Call this once before sending any user related in app events.

fetch_event = FetchToken(client, user_data)
try:
    response = fetch_event.send()
    user_data.set_user_creative_token_info(response)
    print("Creative token information set.")
except Exception as e:
    print("Error fetching creative token:", e)

3. Send In-App Events

Retention Event

The retention event should be sent each time the user opens the app, including after the initial user registration event.

retention_data = RetentionData().set_retention_data(user_data)
retention_event = AppEvent(client, retention_data, user_data)
try:
    response = retention_event.send()
    print("Retention event sent")
except Exception as e:
    print("Error sending retention event:", e)

Purchase Event

purchase_data = PurchaseData() \
    .set_item_id("item_123") \
    .set_item_name("No Ads") \
    .set_value(3.99) \
    .set_currency("usd") \
    .set_status("completed")
purchase_event = AppEvent(client, purchase_data, user_data)
try:
    response = purchase_event.send()
    print("Purchase event sent")
except Exception as e:
    print("Error sending purchase event:", e)

Ad View Event

ad_data = AdData() \
    .set_ad_id("ad_123") \
    .set_name("New Game Ad") \
    .set_source("rewarded_video") \
    .set_media_source("admob") \
    .set_channel("paid") \
    .set_watch_time(4321) \
    .set_reward(True) \
    .set_value(0.00035) \
    .set_currency("usd")
ad_event = AppEvent(client, ad_data, user_data)
try:
    response = ad_event.send()
    print("Ad view event sent")
except Exception as e:
    print("Error sending ad view event:", e)

License

This project is licensed under the terms of the GEEKLAB SDK EULA.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

audiencelab_python_sdk-1.0.2.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

audiencelab_python_sdk-1.0.2-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file audiencelab_python_sdk-1.0.2.tar.gz.

File metadata

  • Download URL: audiencelab_python_sdk-1.0.2.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for audiencelab_python_sdk-1.0.2.tar.gz
Algorithm Hash digest
SHA256 c8c1874add7dc426de3ca4c7ed4db744591338b7fee5a49f47862261826609b6
MD5 ba37efd7bfd0c7a748c5eeb10b9c5cb6
BLAKE2b-256 89788a4b5b08091e7681818d3b9ba52755afe38e6f44872f54454eaf45c90cd9

See more details on using hashes here.

File details

Details for the file audiencelab_python_sdk-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for audiencelab_python_sdk-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1aad4726453161b6fefc35d5f5d741e9c72b2f4c5b1cfbd6d0e6e732c8d73499
MD5 2e18d1a3ea82893cc79787180bdc05cd
BLAKE2b-256 8584aa5d1997b21a9ff68299386e677d812f3819beaa5b9a38f06a5e45fffab4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page