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.1.tar.gz (12.3 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.1-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for audiencelab_python_sdk-1.0.1.tar.gz
Algorithm Hash digest
SHA256 955789e89c41b9107357b2618a0afca2d330a10e4b77d248df5c4807d77c0b4b
MD5 36dc61c41bac4c8ed1396f9857044067
BLAKE2b-256 2bbc387fffda12fad7398bfd376cdb93219a49646fc240238a177686b68ccbd6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for audiencelab_python_sdk-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cb6b5b655f92a05a5d20d2004582d8dc384c2c1e7be42e8cb503d12a7b4a202b
MD5 fc02bbbc12c2f7f0a1926ac73d98d7b2
BLAKE2b-256 0f9f2e0f98012a9fad3bc7f2e9644465fe6e66c1cc77abd85245fbcbbb1479b8

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