Mixpanel model

Events daily

Mixpanel's Insights "Total events" and "Unique users" per event, per day.

Grain
one row per day (UTC) x event name
Built from
  1. 1
    Raw tables
  2. 1
    Staging
  3. 1
    Core
  4. 1
    Analytics
Reads from Mixpanel
events
Ships as
Weld and dbt SQL, open source on GitHub
core.mixpanel_source.events_daily
1-- core.mixpanel_source.events_daily
2-- Mixpanel's Insights "Total events" and "Unique users" per event, per day.
3--
4-- Grain: one row per day (UTC) x event name.
5-- Depends on: staging.mixpanel_source.events
6--
7-- `unique_users` counts distinct `distinct_id` values within the row. They are unique per
8-- day and per event, so they cannot be summed across days or events into unique people;
9-- use active_users_daily for that.
10--
11-- Mixpanel's UI resolves identities (an anonymous device and the user it later logged in
12-- as are one person) and shows days in your project time zone. These counts use the raw
13-- `distinct_id` and UTC days, so uniques can run slightly above Mixpanel's and days can
14-- shift at the edges.
15
16SELECT
17    DATE(event_at)                          AS date,
18    event_name,
19    COUNT(*)                                AS events,
20    COUNT(DISTINCT distinct_id)             AS unique_users,
21    SAFE_DIVIDE(COUNT(*), COUNT(DISTINCT distinct_id)) AS events_per_user
22FROM {{staging.mixpanel_source.events}}
23GROUP BY 1, 2

This model and the 2 it depends on. Deploy them together; refs like {{staging.…}} resolve to the matching folders in Weld, and the dbt view uses source() and ref().

Notes

How it counts. And where it stops.

`unique_users` counts distinct `distinct_id` values within the row. They are unique per day and per event, so they cannot be summed across days or events into unique people; use active_users_daily for that. Mixpanel's UI resolves identities (an anonymous device and the user it later logged in as are one person) and shows days in your project time zone. These counts use the raw `distinct_id` and UTC days, so uniques can run slightly above Mixpanel's and days can shift at the edges.

Raw tables it reads

  • raw.mixpanel_source.events

Put Mixpanel in front
of your agents.

Connect Mixpanel, deploy the models, and ask questions in Claude, Cursor or ChatGPT. Free for 14 days, no credit card.