I have a 'pageview' event pulling into Mixpanel for every user, I would like to view every 'last pageview' as an event, which is the Pageview event, but the one where the timestamp is the largest per user. How would I create this?
Hi James S., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> 👋
Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai
You can do this with a JQL query that, for each user, finds the pageview event with the maximum timestamp using groupByUser. [groupByUser]Here’s an example JQL script: js function main() { return Events({ from_date: "2026-02-01", // adjust date range as needed to_date: "2026-02-20", event_selectors: [{ event: "pageview" }] }) .groupByUser(function (state, events) { // state will hold the latest pageview we've seen for this user state = state || null;LBKS for (var i = 0; i < events.length; i++) { var ev = events[i]; if (!state || ev.time > state.time) { state = ev; // keep the event with the largest timestamp } } return state; }); }LBKSThis returns one record per user: LBKS{ "key": ["<distinct_id> "], "value": { ...the last pageview event for that user... } }LBKSYou can run this in the JQL app to inspect or export all users’ “last pageview” events.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
where would I input this script?
Let me check the knowledge base for you again. One moment! 📚
You would run that script using Mixpanel’s JQL Query API / JQL app.From the docs, JQL is executed by sending your script to the JQL HTTP endpoint: LBKScurl [https://mixpanel.com/api/query/jql](https://mixpanel.com/api/query/jql) \ -u YOUR_API_SECRET: \ --data-urlencode script@my_query.jsLBKSor by passing the script inline in the script parameter. [Custom JQL]So in practice you: 1. Put the JQL code into a file (e.g. my_query.js) or a string.
2. Call [https://mixpanel.com/api/query/jql](https://mixpanel.com/api/query/jql) with:
- script = your JQL code.
- Optionally params = JSON string if you want to pass parameters. [Custom JQL; JQL params]If you’re using a client helper like mixpanel-utils in Python, you pass the script string into query_jql(script, params=None). [mixpanel-utils]
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
Is there no way to pull this in the Mixpanel UI?
Let me check the knowledge base for you again. One moment! 📚
Based on the docs, there isn’t a built‑in “last event per user” selector you can choose directly in the standard UI (Insights, Users, etc.). The closest UI features are: - View Users from a chart point, which shows users contributing to that point and lets you save them as a cohort, but it doesn’t transform events into “only the last per user.” [View Users; Insights View Users]
- Behavioral / computed properties like Frequency per User or Aggregate Property per User, which segment users by counts/aggregates, not “latest event row.” [Computed properties]The knowledge sources don’t describe any UI option that returns just the single latest pageview event per user as an event list. For that specific “max timestamp per user” event selection, the documented way is to use JQL with groupByUser. [groupByUser]So, as far as the provided docs show, this cannot be done purely via point‑and‑click in the UI; it requires JQL or external processing.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
kapa.ai Is there a way to use this within the Mixpanel UI? https://developer.mixpanel.com/reference/raw-event-export I can't use it as our account uses SSO rather than username and password
Let me check the knowledge base for you again. One moment! 📚
You don’t need to use a username/password login in the UI to call the Raw Event Export API, and there’s no way to “run” that endpoint directly inside the Mixpanel UI.From the docs: - Event export is done via the Raw Event Export API (GET /export) and is intended to be called from code or tools (curl, scripts, ETL, etc.), not from a UI screen. [Export methods; Export API]
- Authentication for export should use a Service Account or (legacy) Project Secret, passed as HTTP Basic auth; when using a Service Account you must include project_id as a query parameter. [Export auth]SSO only affects how people log into the Mixpanel web app; it doesn’t block API access. You can: 1. Have an Org Owner/Admin create a Service Account with access to the project.
2. Use that Service Account’s credentials in your script or tool to call the Raw Event Export API, e.g.:
--url '[https://data.mixpanel.com/api/2.0/export?project_id=<YOUR_PROJECT_ID](https://data.mixpanel.com/api/2.0/export?project_id=<YOUR_PROJECT_ID) &from_date=<FROM_DATE> &to_date=<TO_DATE> >' \
--header 'accept: text/plain' \
--header 'authorization: Basic YOUR_TOKEN'
```LBKS [[Project migration export](https://docs.mixpanel.com/guides/strategic-playbooks/project-migration#step-3-export-existing-data)]LBKSIf you specifically need exports **from the UI**, the only built‑in option is the small‑batch **CSV export** from the Events table (no Raw Export there). [[Export methods](https://docs.mixpanel.com/docs/export-methods)]LBKSSo: LBKS- No: you can’t “use `/export` in the UI.”
- Yes: you can use `/export` via API even if your org uses SSO, by authenticating with a Service Account or project secret instead of your personal login.
kapa.ai is still learning and improving, please let me know how I did by reacting below.
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
