Skip to main content
Mixpanel’s client-side SDKs send every event with your project token, and the token is visible to anyone who loads your page. Because of this, although rare in practice, someone else could send events to your project with your token, whether by accident or on purpose. For example, a person might copy your tracking snippet onto their own site. Unwanted events can also come from bot traffic or from test and staging environments that share your token. This guide helps you choose an approach, points to the page that has the procedure for each one, and shows how to check that your change worked. By the end, you can:
  • Explain what a project token does and does not allow.
  • Choose a tracking approach that fits how much control you need.
  • Filter unwanted events as they arrive.
  • Remove unwanted events that are already in your project, and know when to ask Support to replace your project token.

Before you start

  • Some features in this guide depend on your plan and your role in the project. See the pricing page and Roles and permissions to check what you can use.
  • Know where your events come from: browsers, mobile apps, your servers, or a mix. The right approach depends on it.
  • Test tracking changes in a development project before you apply them to production. See Managing projects.

What your project token allows

A project token is a unique value that tells Mixpanel which project should receive your data. It is not a secret. In browser code, anyone who loads your page can see it. See Project Token. Ingestion calls such as Track Events and Set User Profile Properties only require the project token. See Authentication Methods and Ingestion API Authentication. A request that includes your project token can send events or user profile properties to your project. If you track from a browser or mobile app, the token has to be in code your users can read, so no setting makes it private. Client-side analytics tools generally work this way, because the tracking code runs in the browser or app. The options in this guide limit unwanted events and clean them up. Only tracking from your server keeps the token out of client code.

Choose your approach

Each approach addresses a different part of the problem, and you can combine them.

Track from your server only

Tracking only from your server keeps the project token in your backend configuration instead of in page or app code. Your server still initializes the SDK with the token. For example, the Python SDK takes it as an argument:
Replace YOUR_PROJECT_TOKEN with the token from your project’s settings. Your app then needs to send the information to your server, and your server sends the event to Mixpanel. This means you give up tracking directly from the browser or the app. See the Python SDK page. Mixpanel also has server-side SDKs for other languages, such as Node.js and Go. See Choosing the right method for the full list.

Route events through your own domain

A proxy is a server you run that receives events from your site or app and forwards them to Mixpanel. Mixpanel documents a proxy setup for the JavaScript SDK, with a complete nginx configuration and the api_host and lib_base_path settings. See Tracking via proxy. The documented setup forwards requests as they arrive, including the token your client sends. To hide the token, you need a custom proxy that adds the token itself, which the documented setup doesn’t do. Because you run the proxy, you can add your own checks before it forwards a request, such as requiring a signed-in session. Those checks are your own implementation, and this guide doesn’t cover how to build them. If your project uses EU or India data residency, point the proxy at your region’s host, api-eu.mixpanel.com or api-in.mixpanel.com. Events sent to the wrong region aren’t ingested. Note: Mixpanel also offers First-Party Domains, which point a subdomain you own at Mixpanel without a proxy server of your own. This feature is designed to reduce the impact of ad blockers. It does not hide your project token or let you add your own checks, so for that you need a custom proxy. See First-Party Domains and the pricing page for availability.

Filter events as they arrive

Filtering stops events from being stored in your project. Two Lexicon tools do this: Drop Filters and blocking. See Data Clean-Up for the procedures. Both tools act at ingestion. Mixpanel discards matching events as they arrive, so they are never stored. Hiding an event in Lexicon is different: it only removes the event from view. Consider these points when you choose:
  • A Drop Filter needs an event name and at least one property with at least one value. It can’t filter on the event name alone.
  • Blocking an event drops every event with that name, including events from your own app. Use it only when you never want that event.
  • Look at the unwanted events in your project to find a property value that appears on them and never on your own events. Choose a property your app sends with the event. Drop Filters run before Mixpanel adds IP-derived geolocation properties such as mp_country_code, $city, and $region, so a filter on those values won’t stop the unwanted events. See Supported filter criteria.
  • A project can have up to 15 Drop Filters.
  • A Drop Filter becomes active within 10 minutes of creation. A blocked event can take a few hours to take effect. Both affect only events that arrive afterward. To remove events already stored, see the next section.
  • Both Drop Filters and blocking discard events permanently. Dropped events aren’t stored and can’t be recovered.
  • Dropped events don’t count toward your event volume.
  • Blocking an event doesn’t require a new release of your app.
Mixpanel-defined events, which start with $ such as $experiment_started, can’t be dropped. The one exception is $opt_in.

Remove unwanted events already stored

Data Deletion permanently removes events that are already in your project. Bot traffic that clutters an event is a listed use. You can narrow a deletion with event property filters, so you can remove a subset of an otherwise useful event. See Data Clean-Up for the procedure. Data Deletion has these limits:
  • The event time of the data must be within the past 180 days.
  • Event volume must be below 5 billion events per month in each of the trailing 3 months.
  • A project can’t have more than 10 deletes in the past calendar month.
Data Deletion becomes permanent and irreversible 7 days after you submit it. Until then, Mixpanel hides the data from your project and you can undo the request. Removing the data from storage can take up to 30 days in total, and the data might appear in raw exports during that time.
Data Deletion doesn’t delete individual event properties. Use the GDPR API to delete data for a single distinct ID. To delete user profiles, see Bulk delete profiles.

Ask Support to replace your project token

You can’t reset a project token yourself. To replace one, contact Support. Support asks the project owner to approve the replacement and agrees on timing with you. Be ready to update the token in your code as soon as the new one is issued. After Mixpanel rotates it, the original token becomes invalid. Any code that still uses the original token sends data that won’t be ingested into your project, so replace it with the new token everywhere you send data. Users on older versions of your app that still use the original token can lose data, because Mixpanel no longer ingests what those versions send. See Managing projects.

Check that your changes worked

Check each approach you used.

Troubleshooting