GuidesBackend

Rust analytics, cookieless and EU-hosted event tracking

Server-side analytics for Rust services. No cookies, no client, data stored in Germany.

The openpanel_rust crate sends events from your Rust service straight to the Privytics ingestion API over HTTP. You set three environment variables, build a Tracker, and call track() with an event name and a map of properties. Because the events originate on your server, ad blockers and browser privacy settings never touch them.

Why Rust teams use Privytics

Server-side events are not blockable

There is no browser script and no request from the user's device, so content blockers, tracking protection and network filtering have nothing to intercept. Events fire from inside your own service, on the same code path as the business logic that produced them.

Nothing is written to the user's device

The crate is an HTTP client authenticated with a client id and secret. It sets no cookies and no local storage, because it never runs on the visitor's device. Any identifier attached to an event is one you pass yourself as a profile id.

Async, built on Tokio and reqwest

track(), identify() and revenue() are async and return a Result, so they await alongside your existing handlers instead of blocking a worker thread. The crate depends on reqwest and tokio directly, so it drops into an Axum, Actix Web or Tower service without a second runtime.

Endpoint and credentials come from the environment

The tracker reads OPENPANEL_TRACK_URL, OPENPANEL_CLIENT_ID and OPENPANEL_CLIENT_SECRET at startup via Tracker::try_new_from_env(). You point staging and production at different projects without recompiling, and the client secret stays out of the binary and out of version control.

Set it up

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

  1. Install the crate

    The package on crates.io is openpanel_rust. Pin the minor version: the snippets below are written against the 0.4 API. anyhow is only a dev-dependency of the crate, so add it yourself if you want the error handling used in these examples, along with a Tokio runtime for the #[tokio::main] macro.

    cargo add openpanel_rust@0.4
    cargo add tokio --features full
    cargo add anyhow
  2. Point it at Privytics

    Set these three variables in the environment your service starts with. The repository ships a .env_sample for reference. OPENPANEL_TRACK_URL must point at the Privytics ingestion endpoint, and the client id and secret come from your Privytics project settings.

    # .env
    OPENPANEL_TRACK_URL=https://api.privytics.com/track
    OPENPANEL_CLIENT_ID=YOUR_CLIENT_ID
    OPENPANEL_CLIENT_SECRET=YOUR_CLIENT_SECRET
  3. Build a tracker and send an event

    The crate is named openpanel_rust but its library target is openpanel_sdk, so that is what you import. In 0.4 the arguments to track() are the event name, an optional profile id, optional properties, optional groups, and an optional filter closure.

    use openpanel_sdk::sdk::Tracker;
    use std::collections::HashMap;
    
    #[tokio::main]
    async fn main() -> anyhow::Result<()> {
        let tracker = Tracker::try_new_from_env()?.with_default_headers()?;
    
        let mut properties = HashMap::new();
        properties.insert("plan".to_string(), "pro".to_string());
    
        tracker
            .track(
                "signup_completed".to_string(),
                Some("user_123".to_string()),
                Some(properties),
                None,
                None,
            )
            .await?;
    
        Ok(())
    }
  4. Record revenue from the server

    Revenue belongs on the backend, next to the webhook or the transaction that confirmed it, rather than on a checkout page that may never finish loading. revenue() takes an optional profile id, the amount as an i64, and optional properties.

    tracker
        .revenue(Some("user_123".to_string()), 4900, None)
        .await?;

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

Questions

What is the crate name for the OpenPanel Rust SDK?

The published package on crates.io is openpanel_rust, currently 0.4.0, but its library target is named openpanel_sdk. So you install openpanel_rust and write use openpanel_sdk::sdk::Tracker. It is a third-party MIT-licensed crate maintained at github.com/tstaetter/openpanel-rust-sdk, not an official OpenPanel package. Note that the openpanel.dev docs page currently tells you to run cargo add openpanel-sdk, which will fail: no crate by that name exists.

How do I send events to Privytics instead of OpenPanel?

Set OPENPANEL_TRACK_URL to https://api.privytics.com/track in the environment your service reads at startup. Tracker::try_new_from_env() picks it up along with the client id and secret.

Does server-side Rust analytics need a cookie banner?

The SDK runs on your server and writes nothing to the visitor's device, so there is no cookie or local storage to disclose from this integration. You remain the data controller and are responsible for your own lawful basis and privacy notice, particularly if you call identify() or pass your own user ids as profile ids.

Does it work with Axum or Actix Web?

Yes. The tracker is an async HTTP client built on reqwest and tokio, so its methods await inside any Tokio-based handler. Add tokio to your own crate if you need the #[tokio::main] macro.