how to export mixpanel session data to google bigquery ?
The knowledge sources do not explicitly mention a direct method for exporting pre-computed Mixpanel session metrics or the virtual Session Start and Session End events directly to Google BigQuery. In Mixpanel, sessions are computed dynamically at query time from your raw event data [Sessions]. However, you can export your underlying event data to Google BigQuery using Mixpanel's Data Pipelines, and then reconstruct or analyze sessions in SQL.
Step 1: Set Up BigQuery Permissions
Before creating the pipeline, configure your BigQuery dataset to allow Mixpanel to write data:
(Note: If your organization enforces domain restriction constraints, ensure mixpanel.com and customer ID C00m5wrjz are allowed [BigQuery].)
Step 2: Create the BigQuery Pipeline in Mixpanel
You must be a Project Admin or Owner to create a pipeline [Data Pipelines Overview]:
In Mixpanel, navigate to Project Settings > Destinations [Data Pipelines Overview].
Select BigQuery and click + Create Pipeline [Data Pipelines Overview].
Provide the required details [BigQuery]:
GCP project ID
Dataset name
GCP region
Select the data sources you want to export (e.g., events, identity mappings) and configure your start date [BigQuery; Create Pipelines].
Step 3: Query and Recreate Sessions in BigQuery
Once exported, your events will be populated in the mp_master_event table, with properties stored inside a properties JSON column [BigQuery]. Depending on how you define sessions in Mixpanel, you can calculate them in BigQuery:
Property-Based Sessions: If you send a custom session ID with your events (e.g., session_id), extract it in SQL using BigQuery JSON functions [Property-Based Sessions; BigQuery]:SELECT distinct_id, JSON_VALUE(properties, '$.session_id') AS session_id, time, event_name FROM `<your-gcp-project>.<your-dataset>.mp_master_event`
Timeout-Based Sessions: If you use Mixpanel's default timeout sessions (e.g., 30 minutes of inactivity), you can calculate session windows in BigQuery using window functions such as LAG() on the time column to identify periods of user inactivity that exceed your threshold [Timeout-Based Sessions].
ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.
