Troubleshooting Mixpanel JQL: Discrepancies in Session Start Event Counts
We are using Mixpanel to log a single event Session Start . This is in our staging environment and we don't have a lot of data there. For example, in the last 7 days we have 1529 events for the project in total (I am getting this number from the Events tab in the Mixpanel UI when filtering for 7 days). What I'm trying to do is count all of the Session Start events per user so that I can inject it into MongoDB so that we can report against it. The results that I see from the Mixpanel web UI are different than what I see when querying the API via JQL. For example, via the web UI, I see 14 unique user IDs when using a breakdown of Session Start events by User ID, as seen in the attached screenshot. When querying via the API, I only see four users active in the past week. Here is the JQL I am using
function main() {
return Events({
from_date: "2025-01-15",
to_date: "2025-01-22"
})
.filter(function(event) {
const dollarFound = event.distinct_id.indexOf('$')
return event.name === "${filterEvent}" && dollarFound != 0;
})
.groupBy(["distinct_id"], mixpanel.reducer.count());
}
`
I have tried using .groupByUser(mixpanel.reducer.count()), in the above query (and removing the filter), and expanding the date range to 2025-01-13 ..2025-01-23 (9 days in the past and one day in the future), and I still only get 4 results (there are $device results if I remove the filter). The results have some overlap with what is in the screenshot, and I am fairy confident I am querying the correct project ID (2380236). I feel like there must be something trivial I am missing about my understanding of JQL. If somebody could help me look at this I would appreciate it. Thanks.