How to send data to Mixpanel on Mixpanel

intermediate 8 min read Updated 2026-03-18
Quick Answer

To send data to Mixpanel, install the Mixpanel SDK in your application, initialize it with your project token, and use the track() method to send events. You can also send data via HTTP API or import historical data through the web interface.

Prerequisites

  • Active Mixpanel account
  • Basic understanding of JavaScript or API calls
  • Access to your application's codebase
  • Valid project token from Mixpanel

Step-by-Step Instructions

1

Get your project token

Log into your Mixpanel account and navigate to Settings > Project Settings. Copy your Project Token from the overview section. This token is required to authenticate data sent to your project.
Keep your project token secure and never expose it in client-side code for server-side implementations.
2

Install the Mixpanel SDK

For JavaScript applications, install via npm: npm install mixpanel-browser. For Node.js: npm install mixpanel. For mobile apps, add the appropriate SDK: iOS via CocoaPods pod 'Mixpanel' or Android via Gradle implementation 'com.mixpanel.android:mixpanel-android:7.+'.
Choose the SDK that matches your platform - browser SDK for client-side tracking, server SDK for backend events.
3

Initialize Mixpanel in your code

For JavaScript:
import mixpanel from 'mixpanel-browser';
mixpanel.init('YOUR_PROJECT_TOKEN');
For Node.js:
const Mixpanel = require('mixpanel');
const mixpanel = Mixpanel.init('YOUR_PROJECT_TOKEN');
Replace YOUR_PROJECT_TOKEN with the token from step 1.
Initialize Mixpanel early in your application lifecycle to ensure all events are captured.
4

Track your first event

Send an event using the track method:
mixpanel.track('Button Clicked', {
  'button_name': 'Sign Up',
  'page': 'Homepage',
  'user_type': 'Guest'
});
The first parameter is the event name, and the second is an object with event properties.
Use descriptive event names and consistent property naming conventions across your application.
5

Set user properties

Identify users and set their properties:
mixpanel.identify('user123');
mixpanel.people.set({
  '$email': 'user@example.com',
  '$name': 'John Doe',
  'plan': 'Premium'
});
This associates events with specific users and stores user profile data.
Call identify() before setting people properties to ensure they're associated with the correct user.
6

Verify data in Mixpanel dashboard

Go to your Mixpanel dashboard and click on Events in the left sidebar. You should see your tracked events appearing in real-time. Click on Users to view user profiles and properties you've set.
It may take a few minutes for data to appear in the dashboard, especially for the first events.
7

Send data via HTTP API (alternative method)

You can also send events directly via HTTP POST to https://api.mixpanel.com/track:
curl -X POST 'https://api.mixpanel.com/track' \
-d 'data=eyJldmVudCI6ICJCdXR0b24gQ2xpY2tlZCIsICJwcm9wZXJ0aWVzIjogeyJ0b2tlbiI6ICJZT1VSX1RPS0VOIn19'
The data parameter must be base64-encoded JSON.
Use the HTTP API for server-side tracking or when SDKs aren't available for your platform.

Common Issues & Troubleshooting

Events not appearing in dashboard

Check that your project token is correct and that you're looking at the right project. Verify your internet connection and ensure the Mixpanel SDK is properly initialized before tracking events.

CORS errors in browser

Ensure you're using the mixpanel-browser SDK for client-side tracking, not the Node.js version. Check that your domain is whitelisted in Project Settings > CORS if you have restrictions enabled.

User properties not updating

Make sure you call mixpanel.identify() before setting people properties. Verify that you're using the correct method: mixpanel.people.set() for setting properties.

High data volume causing delays

Implement batching for high-frequency events using mixpanel.track_batch() or consider sampling non-critical events. Monitor your event volume in Project Settings > Usage.

Prices mentioned in this guide are pulled from current plan data and may change. Always verify on the official Mixpanel website before purchasing.