Python SDK for Traaaction affiliate tracking and management
Project description
traaaction
Python SDK for Traaaction — affiliate tracking for Python web apps.
Install
pip install traaaction
Quick start
from traaaction import Traaaction
trac = Traaaction() # reads TRAAACTION_API_KEY env var
# or: trac = Traaaction(api_key="pk_live_xxx")
Track a lead (signup)
Call this immediately after creating a user in your database:
trac.track.lead(
click_id=click_id, # from cookie or URL param
event_name="sign_up",
customer_id=str(user.id), # your app's user ID
customer_email=user.email,
customer_name=user.get_full_name(),
)
Stripe checkout metadata
Pass this to stripe.checkout.Session.create():
metadata = trac.stripe_metadata(request, str(user.id))
session = stripe.checkout.Session.create(
line_items=[...],
mode="subscription",
metadata=metadata,
success_url="...",
)
Django integration
1. Install with Django extras
pip install "traaaction[django]"
2. Add middleware
# settings.py
MIDDLEWARE = [
...
"traaaction.django.TraacMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
...
]
# Optional: share cookie across subdomains
TRAC_COOKIE_DOMAIN = ".yourdomain.com"
3. Track events in views
# views.py
from traaaction import Traaaction
from traaaction.django import get_click_id
trac = Traaaction()
def signup_view(request):
# ... create user ...
click_id = get_click_id(request) # reads middleware session or cookies
trac.track.lead(
click_id=click_id,
event_name="sign_up",
customer_id=str(user.id),
customer_email=user.email,
)
return redirect("/dashboard")
def checkout_view(request):
metadata = trac.stripe_metadata(request, str(user.id))
session = stripe.checkout.Session.create(
line_items=[...],
mode="subscription",
metadata=metadata,
success_url=request.build_absolute_uri("/dashboard"),
)
return redirect(session.url)
Environment variables
| Variable | Description |
|---|---|
TRAAACTION_API_KEY |
Your Traaaction publishable key (pk_live_...) |
TRAC_API_KEY |
Legacy alias (backwards compatible) |
How it works
- A seller shares their Traaaction affiliate link (e.g.
traaaction.com/s/mission/abc123) - A customer clicks → lands on your site with
?trac_click_id=clk_xxx - TraacMiddleware captures and persists the click ID (session + cookie)
- On signup:
track.lead()links the customer to the seller - On purchase: Stripe webhook (configured in Traaaction dashboard) automatically creates the commission
Links
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
traaaction-1.2.0.tar.gz
(16.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file traaaction-1.2.0.tar.gz.
File metadata
- Download URL: traaaction-1.2.0.tar.gz
- Upload date:
- Size: 16.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b34b963481fce2dc458b14a767fb26bf4ba350184e76adf56c319d9a82a8d4c
|
|
| MD5 |
2246c8571eb0c737c3a21b4185597714
|
|
| BLAKE2b-256 |
f6c97c3e4ebf64f1864ba6e933ddc8f5eec892bfccb166c8a67410946138a45c
|
File details
Details for the file traaaction-1.2.0-py3-none-any.whl.
File metadata
- Download URL: traaaction-1.2.0-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1604c1a487407d1fa62472bcd9786b108353de3a95b5f86e0d3502f674e289be
|
|
| MD5 |
74ab51f270268236d1627dfd38ba0767
|
|
| BLAKE2b-256 |
f625e4dad2e68d909d5ae1c09c127c42dd554a0a2da9dd5f2ef00391e3401b09
|