Python
Server-side conversion tracking for Django, Flask, FastAPI or a worker.
Send conversions from your own back end. A browser event can be blocked and the customer may never load the confirmation page - the order row in your database always exists, so sending from there is what makes a conversion reliable.
Install
pip install pixelfox-sdkNo dependencies: a tracking SDK should not force a version of requests onto
your project.
Send a purchase
import os
from pixelfox import PixelFox
signals = Signals(api_key=os.environ["SIGNALS_API_KEY"])
signals.purchase(
order_id="1042",
value=1200,
currency="BDT",
# From the `signals_did` cookie, so this joins the same journey as the page
# views that led to it. Without it the sale looks like a new stranger.
distinct_id=request.COOKIES.get("signals_did"),
email=order.email,
items=[{"product_id": "p1", "name": "Merino Crew", "quantity": 2, "price": 600}],
)email and phone are what raise match quality on Meta and TikTok. They are
hashed server-side before reaching any ad platform and never reach a browser.
Identify a visitor
Their earlier anonymous events are re-attributed to them server-side, so calling this after a signup backfills the whole session.
signals.identify(distinct_id=did, email=user.email, phone=user.phone)Batching
For a worker sending many events, buffer and flush once:
with PixelFox(api_key=KEY, batch=True) as signals:
for order in backfill:
signals.purchase(order_id=order.id, value=order.total, currency="BDT")
# flushed on exitBatches larger than 50 are split automatically - the ingest endpoint rejects anything bigger.
Errors
Nothing raises into your request path. Analytics failing must not fail a checkout.
signals = PixelFox(
api_key=KEY,
on_error=lambda msg: logger.warning("signals: %s", msg),
)
result = signals.track("lead_submitted", distinct_id=did)
if not result.ok:
logger.warning(result.error)Reference
| Method | Purpose |
|---|---|
track(event, distinct_id, properties) | Any event |
identify(distinct_id, email, phone) | Attach an identity |
purchase(order_id, value, currency, ...) | A conversion |
flush() | Send buffered events |
timeout defaults to 3 seconds.
Python is online mode only. Offline mode needs somewhere on your own infrastructure to store analytics, which the WordPress plugin has and an SDK does not.