GuidesBackend

Python analytics for Django and Flask, cookieless and EU-hosted

Server-side analytics for Django, Flask and any Python app. Event data stored in the EU.

Privytics tracks product events straight from your Python backend using the open-source OpenPanel Python SDK. You install one package, create a client pointed at your Privytics ingestion URL, and call track() wherever something happens: a signup, a payment, a background job finishing. Setup is about five lines, and because the events come from your server there is no browser script and no cookie involved.

Why Python teams use Privytics

Server-side events do not get blocked

Ad blockers, tracking protection and script blockers act on browser requests. A call from your Django or Flask process is a plain outbound HTTPS request from your own infrastructure, so events like signup_completed and subscription_renewed arrive regardless of what the visitor runs client-side.

Track what the browser never sees

Stripe and other webhooks, Celery and RQ tasks, cron jobs, management commands and API-only clients all run with no page open. These are usually the events that matter most commercially, and the Python SDK is the only way to record them.

Your request handler never waits on the network

Each call schedules the HTTP request onto a background daemon thread running its own asyncio event loop and returns immediately. Adding tracking to a hot Django view does not add latency to the response. Note that the send itself is a blocking requests.post on that single background thread, so events are delivered one at a time rather than in parallel.

No cookies and nothing stored on the device

Server-side tracking writes nothing to the visitor's browser. If you want cross-session profiles you pass your own user id to identify(), which is opt-in and under your control, so you decide the lawful basis rather than inheriting one from a tracking script.

Set it up

About five minutes, on the free plan, without a credit card.

  1. Install the package

    The SDK is published on PyPI under the name openpanel. It requires Python 3.7 or newer and pulls in requests as its only dependency.

    pip install openpanel
  2. Create the client

    Always pass api_url. It is an optional argument that defaults to OpenPanel's own host, so if you leave it out your events go to the wrong place. client_secret is needed for server-side events. The optional disabled flag is handy for local development.

    import os
    
    from openpanel import OpenPanel
    
    op = OpenPanel(
        client_id="YOUR_CLIENT_ID",
        client_secret=os.environ["PRIVYTICS_CLIENT_SECRET"],
        api_url="https://api.privytics.com",
        disabled=os.getenv("ENV") == "development",
    )
  3. Track an event

    track() takes an event name and an optional dictionary of properties. Properties are merged with anything you have set through set_global_properties(). Delivery failures are logged to stdout rather than raised, so a tracking outage will never break a request.

    op.set_global_properties({
        "app_version": "1.4.0",
        "environment": "production",
    })
    
    op.track("signup_completed")
    
    op.track("purchase_completed", {
        "plan": "pro",
        "price": 99.99,
        "currency": "EUR",
    })
  4. Attach events to a user in Django or Flask

    identify() sends profile traits and also stores the profile id on the client instance, where every later track() call picks it up. That state is shared across threads, so in a web server one request's identify() can attribute another request's events. Call identify() deliberately, or keep a client per worker. increment() and decrement() take positional arguments and are unaffected, since you pass the profile id explicitly.

    from flask import Flask, jsonify
    
    app = Flask(__name__)
    
    
    @app.post("/checkout")
    def checkout():
        user = get_current_user()
    
        op.identify(str(user.id), {
            "email": user.email,
            "firstName": user.first_name,
        })
    
        op.track("checkout_started", {"cart_value": 49.0})
        op.increment(str(user.id), "checkout_count", 1)
    
        return jsonify(ok=True)

Privytics runs the open-source OpenPanel engine, so the upstream Python SDK reference applies here too. Point apiUrl at Privytics and the data lands in your Privytics project.

Questions

Does the OpenPanel Python SDK work with Django and Flask?

Yes. It is a plain Python library with no framework coupling, so it works in Django views, Flask routes, FastAPI handlers, Celery tasks and standalone scripts. There is no Django or Flask specific integration package, you create one client and call it from your code.

Will ad blockers block Python analytics events?

No. The events are sent from your own server as outbound HTTPS requests, so browser-side blockers and tracking protection never see them. This is the main reason to track conversions and payments server-side.

Do I need a cookie banner for server-side Python tracking?

Server-side tracking sets no cookies and stores nothing on the visitor's device, so there is nothing for a banner to consent to. If you call identify() with your own user id you are building a persistent profile, which needs your own lawful basis. You remain the data controller either way.

How do I point the SDK at Privytics instead of OpenPanel?

Pass api_url="https://api.privytics.com" to the OpenPanel constructor. The argument is optional and defaults to OpenPanel's own host, so you must set it explicitly or your events will go to the wrong place.