# Table of Contents
- [What is Mixpanel? - Mixpanel Docs](#what-is-mixpanel-mixpanel-docs)
- [ Install Mixpanel - Mixpanel Docs](#-install-mixpanel-mixpanel-docs)
- [ Install Mixpanel - Mixpanel Docs](#-install-mixpanel-mixpanel-docs)
- [ Install Mixpanel - Mixpanel Docs](#-install-mixpanel-mixpanel-docs)
- [ Install Mixpanel - Mixpanel Docs](#-install-mixpanel-mixpanel-docs)
- [ Install Mixpanel - Mixpanel Docs](#-install-mixpanel-mixpanel-docs)
- [ Install Mixpanel - Mixpanel Docs](#-install-mixpanel-mixpanel-docs)
- [ Install Mixpanel - Mixpanel Docs](#-install-mixpanel-mixpanel-docs)
- [ Install Mixpanel - Mixpanel Docs](#-install-mixpanel-mixpanel-docs)
- [ Install Mixpanel - Mixpanel Docs](#-install-mixpanel-mixpanel-docs)
---
# What is Mixpanel? - Mixpanel Docs
DocsWhat is Mixpanel?
What is Mixpanel?
=================
Mixpanel will help you better understand your customers and answer questions about your product. It enables you to track how users engage with your product and analyze this data with interactive reports that let you query and visualize the results with just a few clicks.
Mixpanel is built on three key concepts: [**Events**](https://docs.mixpanel.com/docs/what-is-mixpanel#events)
, [**Users**](https://docs.mixpanel.com/docs/what-is-mixpanel#users)
, and [**Properties**](https://docs.mixpanel.com/docs/what-is-mixpanel#properties)
.
Concepts[](https://docs.mixpanel.com/docs/what-is-mixpanel#concepts)
---------------------------------------------------------------------
Before you get started, you should know three Mixpanel concepts:
* **Events** are actions that happen in your product
* **Users** are the people who use your product
* **Properties** are the attributes of your users and events
### Events[](https://docs.mixpanel.com/docs/what-is-mixpanel#events)
An event is a data point that represents an interaction between a user and your product. Events can be a wide range of interactions.
Imagine you run a cafe where customers can purchase a coffee via an app. Each purchase is an event that can be tracked in Mixpanel.

### Users[](https://docs.mixpanel.com/docs/what-is-mixpanel#users)
On the other side of an event is a user — the specific individual who completed an interaction with your product.
Each user has a unique identifier that you can use to track their activity. This identifier can be an email address, a username, or a unique ID. Mixpanel uses a unique ID to identify users.

### Properties[](https://docs.mixpanel.com/docs/what-is-mixpanel#properties)
You can track additional information about **users** and **events**. These details are called **properties**.
An **Event Property** describes an event. For a coffee purchase, the event would be _Purchased Item_ and the event properties could be _type_ (in this case a Coffee) and _price_ (in this case $2.50).

A **User Property** describes a User. This could be their name, email, age, etc.

Properties allow you to create groups of users (aka [cohorts](https://docs.mixpanel.com/docs/users/cohorts)
) and also enable you to filter for certain events or users. These powerful features make it easy to identify trends and new customer insights.
* * *
Next Steps[](https://docs.mixpanel.com/docs/what-is-mixpanel#next-steps)
-------------------------------------------------------------------------
Now that you understand the basics, **we recommend planning the first events you would like to track**. This will help you understand what you need to get started. Choosing these events should take no more than 5 minutes.
Plan Your Tracked Events
####
Already Know What You Want to Track?
If you already know the events you want to track, you can skip planning and start by installing Mixpanel.
Install Mixpanel
[What to Track](https://docs.mixpanel.com/docs/what-to-track "What to Track")
Was this page useful?
YesCould be better
---
# Install Mixpanel - Mixpanel Docs
Docs[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
Install Mixpanel
 Install Mixpanel
=======================================================================================================
Overview[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=javascript#overview)
-----------------------------------------------------------------------------------------------
Installing Mixpanel is easy. This guide will show you how to do it with our SDKs.
Already collect product data? Connect your **[Data Warehouse](https://docs.mixpanel.com/docs/tracking-methods/warehouse-connectors)
** or via **[3rd Party Integrations](https://docs.mixpanel.com/docs/tracking-methods/integrations)
**.
Code[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=javascript#code)
---------------------------------------------------------------------------------------
Choose from the methods below. Not sure how to choose? [Read our guide](https://docs.mixpanel.com/docs/tracking-methods/choosing-the-right-method)
.
JavascriptPythonPHPNodeGoRubyJavaReact NativeFlutteriOS (Objective-C)iOS (Swift)AndroidUnityHTTP API
##### Install the SDK
snippetnpmyarn
npm install --save mixpanel-browser
yarn add mixpanel-browser
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
You can learn more about configuring Session Replay and Heatmaps [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript/javascript-replay)
.
//Import Mixpanel SDK
import mixpanel from "mixpanel-browser";
// Near entry of your product, init Mixpanel
mixpanel.init("YOUR_TOKEN", {
debug: true,
track_pageview: true,
persistence: "localStorage",
record_sessions_percent: 100, //records 100% of all sessions
record_heatmap_data: true,
});
##### Install the SDK
pip install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
from mixpanel import Mixpanel
mp = Mixpanel("YOUR_TOKEN")
##### Install the SDK
**Install with Composer**
1. Add mixpanel/mixpanel-php as a dependency and run composer update:
"require": {
...
"mixpanel/mixpanel-php" : "2.*"
...
}
**Install Manually**
1. [Download the Mixpanel PHP Library](https://github.com/mixpanel/mixpanel-php/archive/master.zip)
2. Extract the zip file to a directory called “mixpanel-php” in your project root
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
##### Install the SDK
npm install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
// Grab the Mixpanel factory
var Mixpanel = require("mixpanel");
// Create an instance of the mixpanel client
var mixpanel = Mixpanel.init("YOUR_TOKEN");
##### Install the SDK
go get github.com/mixpanel/mixpanel-go
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
package main
import (
"context"
"github.com/mixpanel/mixpanel-go"
)
func main() {
ctx := context.Background()
mp := mixpanel.NewApiClient("YOUR_TOKEN")
}
##### Install the SDK
gem install mixpanel-ruby
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
require 'mixpanel-ruby'
mp = Mixpanel::Tracker.new(YOUR_TOKEN)
##### Install the SDK
com.mixpanel
mixpanel-java
1.4.4
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import com.mixpanel.mixpanelapi.MessageBuilder;
import com.mixpanel.mixpanelapi.MixpanelAPI;
// Set up an instance of MixpanelAPI
MixpanelAPI mixpanel = new MixpanelAPI();
MessageBuilder messageBuilder = new MessageBuilder('YOUR_TOKEN');
##### Install the SDK
Under your app’s root directory, run:
npm install mixpanel-react-native
Under your application’s iOS folder, run:
pod install
Note: For XCode 12.5+, there is a known compile issue, please refer to this [workaround](https://github.com/mixpanel/mixpanel-react-native/issues/43#issuecomment-829599732)
.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import { Mixpanel } from "mixpanel-react-native";
// Set up an instance of Mixpanel
const trackAutomaticEvents = false;
const mixpanel = new Mixpanel("YOUR_TOKEN", trackAutomaticEvents);
mixpanel.init();
##### Install the SDK
Add `mixpanel_flutter: ^2.0.0` to your package’s pubspec.yaml file and run:
flutter pub get
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import 'package:mixpanel_flutter/mixpanel_flutter.dart';
class _YourClassState extends State {
Mixpanel mixpanel;
@override
void initState() {
super.initState();
initMixpanel();
}
Future initMixpanel() async {
// Once you've called this method once, you can access `mixpanel` throughout the rest of your application.
mixpanel = await Mixpanel.init("YOUR_TOKEN", trackAutomaticEvents: false);
}
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+ 1. In Xcode, select File > Swift Packages > Add Package Dependency. 2. Follow the prompts using the URL for this repository and must select a version greater than or equal to v4.0.0
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel'`. 2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-iphone"` to your Cartfile.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
#import "Mixpanel/Mixpanel.h"
- (BOOL)application:(UIApplication _)application
didFinishLaunchingWithOptions:(NSDictionary _)launchOptions {
...
Mixpanel \*mixpanel = [Mixpanel sharedInstanceWithToken:@"YOUR_TOKEN"\
trackAutomaticEvents: NO];
...
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+
1. In Xcode, select File > Swift Packages > Add Package Dependency.
2. Paste the URL `https://github.com/mixpanel/mixpanel-swift` and a minimum semantic version of v2.8.0.
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel-swift'`.
2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-swift"` to your Cartfile.
##### Configure the SDK
1. Import Mixpanel into `AppDelegate.swift`
2. Initialize Mixpanel within `application:didFinishLaunchingWithOptions` as seen below
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import Mixpanel
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
...
// Replace with your Project Token
Mixpanel.initialize(token: "YOUR_TOKEN", trackAutomaticEvents: false)
...
}
##### Install the SDK
Add `implementation 'com.mixpanel.android:mixpanel-android:7.+'` as a dependency to your `build.gradle` file.
Once you’ve updated `build.gradle`, you can force Android Studio to sync with your new configuration by clicking the Sync Project with Gradle Files icon at the top of the window: 
If it cannot find the dependency, you should make sure you’ve specified `mavenCentral()` as a repository in `build.gradle`.
Next, add the following permissions in your AndroidManifest.xml:
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import com.mixpanel.android.mpmetrics.MixpanelAPI;
public class MainActivity extends ActionBarActivity {
private MixpanelAPI mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
trackAutomaticEvents = false;
// Replace with your Project Token
mp = MixpanelAPI.getInstance(this, "YOUR_TOKEN", trackAutomaticEvents);
}
}
##### Install the SDK
Add `https://github.com/mixpanel/mixpanel-unity.git#master` to the dependencies section of `com.mixpanel.unity`.
Alternatively, you can download and install the .unitypackage file from our [releases page](https://github.com/mixpanel/mixpanel-unity/releases)
.
##### Configure the SDK
To initialize the library, first open the unity project settings menu for Mixpanel. (Edit -> Project Settings -> Mixpanel) Then, enter your project token into the Token and Debug Token input fields within the inspector. You can find your token [here](https://mixpanel.com/settings/project)
.

Note: If you prefer to initialize Mixpanel manually, you can select the `Manual Initialization` in the settings and call `Mixpanel.Init()` to initialize.
To use mixpanel, add the following sample code to a part of your application:
using mixpanel;
You’re
##### Install the SDK
No install required
Using the HTTP API does not require an installation. **You’re ready to move to the next step.**
Integration / Framework Guides
==============================
[Segment](https://docs.mixpanel.com/docs/tracking-methods/integrations/segment)
[Google Tag Manager](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-tag-manager)
[Ad Spend](https://docs.mixpanel.com/docs/tracking-methods/integrations/ad-spend)
[Amazon S3](https://docs.mixpanel.com/docs/tracking-methods/integrations/amazon-s3)
[Amazon Kafka](https://docs.mixpanel.com/docs/tracking-methods/integrations/aws-kafka)
[CMS & E-Commerce](https://docs.mixpanel.com/docs/tracking-methods/integrations/cms-ecommerce)
[Customer.io](https://customer.io/docs/cdp/destinations/connections/mixpanel?utm_source=mixpanel&utm_medium=partner)
[Freshpaint](https://docs.mixpanel.com/docs/tracking-methods/integrations/freshpaint)
[Google Cloud Storage](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-cloud-storage)
[Google Pubsub](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-pubsub)
[Google Sheets](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-sheets)
[Langfuse](https://docs.mixpanel.com/docs/tracking-methods/integrations/langfuse)
[LaunchDarkly](https://docs.mixpanel.com/docs/tracking-methods/integrations/launchdarkly)
[mParticle](https://docs.mixpanel.com/docs/tracking-methods/integrations/mparticle)
[Next.js](https://docs.mixpanel.com/docs/tracking-methods/integrations/nextjs)
[Mobile Attribution Tracking](https://docs.mixpanel.com/docs/tracking-methods/integrations/mobile-attribution-tracking)
[Rudderstack](https://docs.mixpanel.com/docs/tracking-methods/integrations/rudderstack)
[Shopify](https://docs.mixpanel.com/docs/tracking-methods/integrations/shopify)
[Vendo for Shopify ↗](https://apps.shopify.com/vendo?utm_source=mixpanel&utm_medium=partner)
[Snowplow](https://docs.mixpanel.com/docs/tracking-methods/integrations/snowplow)
[Stripe](https://docs.mixpanel.com/docs/tracking-methods/integrations/stripe)
[Tealium](https://docs.mixpanel.com/docs/tracking-methods/integrations/tealium)
* * *
Next: Identify Your Users
-----------------------------
With Mixpanel installed, you’re now ready to identify the users who use your product.
Identify Your Users
FAQ[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=javascript#faq)
-------------------------------------------------------------------------------------
**Does Mixpanel automatically track page views?**
Yes, if you pass `track_pageview: true` in the `mixpanel.init()` call, Mixpanel will automatically track a “Page View” event every time a new page is loaded. Learn more [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript#tracking-page-views)
.
**What are the recommended web configuration options?**
When tracking on web, we recommend using localStorage, as this is more reliable:
mixpanel.set_config({ persistence: "localStorage" });
Please note that cross-subdomain tracking is not possible when using local storage. If your implementation requires cross-subdomain tracking, remove the persistence flag and use the default “cookie” persistence option.
**Does Mixpanel use third-party cookies?**
No, our Mixpanel JavaScript SDK does not set or use any third-party cookies. If you wish to disable cookies entirely, you can set the disable\_persistence option to true when initializing your Mixpanel JS instance. Note that disabling persistence will disable the use of super properties and anonymous -> identified user tracking.
**How can I track in a privacy compliant way?**
If a user opts out of tracking, you can call the `.optOutTracking()` method on any of our client-side SDKs; this prevents any subsequent data being tracked from that user’s device. Learn more [here](https://docs.mixpanel.com/docs/privacy/protecting-user-data)
.
For iOS specifically: Mixpanel does not use IDFA, so it does not require user permission through the AppTrackingTransparency(ATT) framework. For more details, refer to our [Apple App Developer Privacy Guidance](https://mixpanel.com/legal/app-store-privacy-details)
.
[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
[Identify Users](https://docs.mixpanel.com/docs/quickstart/identify-users "Identify Users")
Was this page useful?
YesCould be better
---
# Install Mixpanel - Mixpanel Docs
Docs[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
Install Mixpanel
 Install Mixpanel
=======================================================================================================
Overview[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=ruby#overview)
-----------------------------------------------------------------------------------------
Installing Mixpanel is easy. This guide will show you how to do it with our SDKs.
Already collect product data? Connect your **[Data Warehouse](https://docs.mixpanel.com/docs/tracking-methods/warehouse-connectors)
** or via **[3rd Party Integrations](https://docs.mixpanel.com/docs/tracking-methods/integrations)
**.
Code[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=ruby#code)
---------------------------------------------------------------------------------
Choose from the methods below. Not sure how to choose? [Read our guide](https://docs.mixpanel.com/docs/tracking-methods/choosing-the-right-method)
.
JavascriptPythonPHPNodeGoRubyJavaReact NativeFlutteriOS (Objective-C)iOS (Swift)AndroidUnityHTTP API
##### Install the SDK
snippetnpmyarn
npm install --save mixpanel-browser
yarn add mixpanel-browser
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
You can learn more about configuring Session Replay and Heatmaps [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript/javascript-replay)
.
//Import Mixpanel SDK
import mixpanel from "mixpanel-browser";
// Near entry of your product, init Mixpanel
mixpanel.init("YOUR_TOKEN", {
debug: true,
track_pageview: true,
persistence: "localStorage",
record_sessions_percent: 100, //records 100% of all sessions
record_heatmap_data: true,
});
##### Install the SDK
pip install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
from mixpanel import Mixpanel
mp = Mixpanel("YOUR_TOKEN")
##### Install the SDK
**Install with Composer**
1. Add mixpanel/mixpanel-php as a dependency and run composer update:
"require": {
...
"mixpanel/mixpanel-php" : "2.*"
...
}
**Install Manually**
1. [Download the Mixpanel PHP Library](https://github.com/mixpanel/mixpanel-php/archive/master.zip)
2. Extract the zip file to a directory called “mixpanel-php” in your project root
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
##### Install the SDK
npm install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
// Grab the Mixpanel factory
var Mixpanel = require("mixpanel");
// Create an instance of the mixpanel client
var mixpanel = Mixpanel.init("YOUR_TOKEN");
##### Install the SDK
go get github.com/mixpanel/mixpanel-go
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
package main
import (
"context"
"github.com/mixpanel/mixpanel-go"
)
func main() {
ctx := context.Background()
mp := mixpanel.NewApiClient("YOUR_TOKEN")
}
##### Install the SDK
gem install mixpanel-ruby
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
require 'mixpanel-ruby'
mp = Mixpanel::Tracker.new(YOUR_TOKEN)
##### Install the SDK
com.mixpanel
mixpanel-java
1.4.4
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import com.mixpanel.mixpanelapi.MessageBuilder;
import com.mixpanel.mixpanelapi.MixpanelAPI;
// Set up an instance of MixpanelAPI
MixpanelAPI mixpanel = new MixpanelAPI();
MessageBuilder messageBuilder = new MessageBuilder('YOUR_TOKEN');
##### Install the SDK
Under your app’s root directory, run:
npm install mixpanel-react-native
Under your application’s iOS folder, run:
pod install
Note: For XCode 12.5+, there is a known compile issue, please refer to this [workaround](https://github.com/mixpanel/mixpanel-react-native/issues/43#issuecomment-829599732)
.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import { Mixpanel } from "mixpanel-react-native";
// Set up an instance of Mixpanel
const trackAutomaticEvents = false;
const mixpanel = new Mixpanel("YOUR_TOKEN", trackAutomaticEvents);
mixpanel.init();
##### Install the SDK
Add `mixpanel_flutter: ^2.0.0` to your package’s pubspec.yaml file and run:
flutter pub get
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import 'package:mixpanel_flutter/mixpanel_flutter.dart';
class _YourClassState extends State {
Mixpanel mixpanel;
@override
void initState() {
super.initState();
initMixpanel();
}
Future initMixpanel() async {
// Once you've called this method once, you can access `mixpanel` throughout the rest of your application.
mixpanel = await Mixpanel.init("YOUR_TOKEN", trackAutomaticEvents: false);
}
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+ 1. In Xcode, select File > Swift Packages > Add Package Dependency. 2. Follow the prompts using the URL for this repository and must select a version greater than or equal to v4.0.0
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel'`. 2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-iphone"` to your Cartfile.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
#import "Mixpanel/Mixpanel.h"
- (BOOL)application:(UIApplication _)application
didFinishLaunchingWithOptions:(NSDictionary _)launchOptions {
...
Mixpanel \*mixpanel = [Mixpanel sharedInstanceWithToken:@"YOUR_TOKEN"\
trackAutomaticEvents: NO];
...
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+
1. In Xcode, select File > Swift Packages > Add Package Dependency.
2. Paste the URL `https://github.com/mixpanel/mixpanel-swift` and a minimum semantic version of v2.8.0.
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel-swift'`.
2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-swift"` to your Cartfile.
##### Configure the SDK
1. Import Mixpanel into `AppDelegate.swift`
2. Initialize Mixpanel within `application:didFinishLaunchingWithOptions` as seen below
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import Mixpanel
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
...
// Replace with your Project Token
Mixpanel.initialize(token: "YOUR_TOKEN", trackAutomaticEvents: false)
...
}
##### Install the SDK
Add `implementation 'com.mixpanel.android:mixpanel-android:7.+'` as a dependency to your `build.gradle` file.
Once you’ve updated `build.gradle`, you can force Android Studio to sync with your new configuration by clicking the Sync Project with Gradle Files icon at the top of the window: 
If it cannot find the dependency, you should make sure you’ve specified `mavenCentral()` as a repository in `build.gradle`.
Next, add the following permissions in your AndroidManifest.xml:
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import com.mixpanel.android.mpmetrics.MixpanelAPI;
public class MainActivity extends ActionBarActivity {
private MixpanelAPI mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
trackAutomaticEvents = false;
// Replace with your Project Token
mp = MixpanelAPI.getInstance(this, "YOUR_TOKEN", trackAutomaticEvents);
}
}
##### Install the SDK
Add `https://github.com/mixpanel/mixpanel-unity.git#master` to the dependencies section of `com.mixpanel.unity`.
Alternatively, you can download and install the .unitypackage file from our [releases page](https://github.com/mixpanel/mixpanel-unity/releases)
.
##### Configure the SDK
To initialize the library, first open the unity project settings menu for Mixpanel. (Edit -> Project Settings -> Mixpanel) Then, enter your project token into the Token and Debug Token input fields within the inspector. You can find your token [here](https://mixpanel.com/settings/project)
.

Note: If you prefer to initialize Mixpanel manually, you can select the `Manual Initialization` in the settings and call `Mixpanel.Init()` to initialize.
To use mixpanel, add the following sample code to a part of your application:
using mixpanel;
You’re
##### Install the SDK
No install required
Using the HTTP API does not require an installation. **You’re ready to move to the next step.**
Integration / Framework Guides
==============================
[Segment](https://docs.mixpanel.com/docs/tracking-methods/integrations/segment)
[Google Tag Manager](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-tag-manager)
[Ad Spend](https://docs.mixpanel.com/docs/tracking-methods/integrations/ad-spend)
[Amazon S3](https://docs.mixpanel.com/docs/tracking-methods/integrations/amazon-s3)
[Amazon Kafka](https://docs.mixpanel.com/docs/tracking-methods/integrations/aws-kafka)
[CMS & E-Commerce](https://docs.mixpanel.com/docs/tracking-methods/integrations/cms-ecommerce)
[Customer.io](https://customer.io/docs/cdp/destinations/connections/mixpanel?utm_source=mixpanel&utm_medium=partner)
[Freshpaint](https://docs.mixpanel.com/docs/tracking-methods/integrations/freshpaint)
[Google Cloud Storage](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-cloud-storage)
[Google Pubsub](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-pubsub)
[Google Sheets](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-sheets)
[Langfuse](https://docs.mixpanel.com/docs/tracking-methods/integrations/langfuse)
[LaunchDarkly](https://docs.mixpanel.com/docs/tracking-methods/integrations/launchdarkly)
[mParticle](https://docs.mixpanel.com/docs/tracking-methods/integrations/mparticle)
[Next.js](https://docs.mixpanel.com/docs/tracking-methods/integrations/nextjs)
[Mobile Attribution Tracking](https://docs.mixpanel.com/docs/tracking-methods/integrations/mobile-attribution-tracking)
[Rudderstack](https://docs.mixpanel.com/docs/tracking-methods/integrations/rudderstack)
[Shopify](https://docs.mixpanel.com/docs/tracking-methods/integrations/shopify)
[Vendo for Shopify ↗](https://apps.shopify.com/vendo?utm_source=mixpanel&utm_medium=partner)
[Snowplow](https://docs.mixpanel.com/docs/tracking-methods/integrations/snowplow)
[Stripe](https://docs.mixpanel.com/docs/tracking-methods/integrations/stripe)
[Tealium](https://docs.mixpanel.com/docs/tracking-methods/integrations/tealium)
* * *
Next: Identify Your Users
-----------------------------
With Mixpanel installed, you’re now ready to identify the users who use your product.
Identify Your Users
FAQ[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=ruby#faq)
-------------------------------------------------------------------------------
**Does Mixpanel automatically track page views?**
Yes, if you pass `track_pageview: true` in the `mixpanel.init()` call, Mixpanel will automatically track a “Page View” event every time a new page is loaded. Learn more [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript#tracking-page-views)
.
**What are the recommended web configuration options?**
When tracking on web, we recommend using localStorage, as this is more reliable:
mixpanel.set_config({ persistence: "localStorage" });
Please note that cross-subdomain tracking is not possible when using local storage. If your implementation requires cross-subdomain tracking, remove the persistence flag and use the default “cookie” persistence option.
**Does Mixpanel use third-party cookies?**
No, our Mixpanel JavaScript SDK does not set or use any third-party cookies. If you wish to disable cookies entirely, you can set the disable\_persistence option to true when initializing your Mixpanel JS instance. Note that disabling persistence will disable the use of super properties and anonymous -> identified user tracking.
**How can I track in a privacy compliant way?**
If a user opts out of tracking, you can call the `.optOutTracking()` method on any of our client-side SDKs; this prevents any subsequent data being tracked from that user’s device. Learn more [here](https://docs.mixpanel.com/docs/privacy/protecting-user-data)
.
For iOS specifically: Mixpanel does not use IDFA, so it does not require user permission through the AppTrackingTransparency(ATT) framework. For more details, refer to our [Apple App Developer Privacy Guidance](https://mixpanel.com/legal/app-store-privacy-details)
.
[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
[Identify Users](https://docs.mixpanel.com/docs/quickstart/identify-users "Identify Users")
Was this page useful?
YesCould be better
---
# Install Mixpanel - Mixpanel Docs
Docs[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
Install Mixpanel
 Install Mixpanel
=======================================================================================================
Overview[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=android#overview)
--------------------------------------------------------------------------------------------
Installing Mixpanel is easy. This guide will show you how to do it with our SDKs.
Already collect product data? Connect your **[Data Warehouse](https://docs.mixpanel.com/docs/tracking-methods/warehouse-connectors)
** or via **[3rd Party Integrations](https://docs.mixpanel.com/docs/tracking-methods/integrations)
**.
Code[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=android#code)
------------------------------------------------------------------------------------
Choose from the methods below. Not sure how to choose? [Read our guide](https://docs.mixpanel.com/docs/tracking-methods/choosing-the-right-method)
.
JavascriptPythonPHPNodeGoRubyJavaReact NativeFlutteriOS (Objective-C)iOS (Swift)AndroidUnityHTTP API
##### Install the SDK
snippetnpmyarn
npm install --save mixpanel-browser
yarn add mixpanel-browser
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
You can learn more about configuring Session Replay and Heatmaps [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript/javascript-replay)
.
//Import Mixpanel SDK
import mixpanel from "mixpanel-browser";
// Near entry of your product, init Mixpanel
mixpanel.init("YOUR_TOKEN", {
debug: true,
track_pageview: true,
persistence: "localStorage",
record_sessions_percent: 100, //records 100% of all sessions
record_heatmap_data: true,
});
##### Install the SDK
pip install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
from mixpanel import Mixpanel
mp = Mixpanel("YOUR_TOKEN")
##### Install the SDK
**Install with Composer**
1. Add mixpanel/mixpanel-php as a dependency and run composer update:
"require": {
...
"mixpanel/mixpanel-php" : "2.*"
...
}
**Install Manually**
1. [Download the Mixpanel PHP Library](https://github.com/mixpanel/mixpanel-php/archive/master.zip)
2. Extract the zip file to a directory called “mixpanel-php” in your project root
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
##### Install the SDK
npm install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
// Grab the Mixpanel factory
var Mixpanel = require("mixpanel");
// Create an instance of the mixpanel client
var mixpanel = Mixpanel.init("YOUR_TOKEN");
##### Install the SDK
go get github.com/mixpanel/mixpanel-go
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
package main
import (
"context"
"github.com/mixpanel/mixpanel-go"
)
func main() {
ctx := context.Background()
mp := mixpanel.NewApiClient("YOUR_TOKEN")
}
##### Install the SDK
gem install mixpanel-ruby
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
require 'mixpanel-ruby'
mp = Mixpanel::Tracker.new(YOUR_TOKEN)
##### Install the SDK
com.mixpanel
mixpanel-java
1.4.4
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import com.mixpanel.mixpanelapi.MessageBuilder;
import com.mixpanel.mixpanelapi.MixpanelAPI;
// Set up an instance of MixpanelAPI
MixpanelAPI mixpanel = new MixpanelAPI();
MessageBuilder messageBuilder = new MessageBuilder('YOUR_TOKEN');
##### Install the SDK
Under your app’s root directory, run:
npm install mixpanel-react-native
Under your application’s iOS folder, run:
pod install
Note: For XCode 12.5+, there is a known compile issue, please refer to this [workaround](https://github.com/mixpanel/mixpanel-react-native/issues/43#issuecomment-829599732)
.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import { Mixpanel } from "mixpanel-react-native";
// Set up an instance of Mixpanel
const trackAutomaticEvents = false;
const mixpanel = new Mixpanel("YOUR_TOKEN", trackAutomaticEvents);
mixpanel.init();
##### Install the SDK
Add `mixpanel_flutter: ^2.0.0` to your package’s pubspec.yaml file and run:
flutter pub get
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import 'package:mixpanel_flutter/mixpanel_flutter.dart';
class _YourClassState extends State {
Mixpanel mixpanel;
@override
void initState() {
super.initState();
initMixpanel();
}
Future initMixpanel() async {
// Once you've called this method once, you can access `mixpanel` throughout the rest of your application.
mixpanel = await Mixpanel.init("YOUR_TOKEN", trackAutomaticEvents: false);
}
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+ 1. In Xcode, select File > Swift Packages > Add Package Dependency. 2. Follow the prompts using the URL for this repository and must select a version greater than or equal to v4.0.0
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel'`. 2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-iphone"` to your Cartfile.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
#import "Mixpanel/Mixpanel.h"
- (BOOL)application:(UIApplication _)application
didFinishLaunchingWithOptions:(NSDictionary _)launchOptions {
...
Mixpanel \*mixpanel = [Mixpanel sharedInstanceWithToken:@"YOUR_TOKEN"\
trackAutomaticEvents: NO];
...
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+
1. In Xcode, select File > Swift Packages > Add Package Dependency.
2. Paste the URL `https://github.com/mixpanel/mixpanel-swift` and a minimum semantic version of v2.8.0.
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel-swift'`.
2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-swift"` to your Cartfile.
##### Configure the SDK
1. Import Mixpanel into `AppDelegate.swift`
2. Initialize Mixpanel within `application:didFinishLaunchingWithOptions` as seen below
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import Mixpanel
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
...
// Replace with your Project Token
Mixpanel.initialize(token: "YOUR_TOKEN", trackAutomaticEvents: false)
...
}
##### Install the SDK
Add `implementation 'com.mixpanel.android:mixpanel-android:7.+'` as a dependency to your `build.gradle` file.
Once you’ve updated `build.gradle`, you can force Android Studio to sync with your new configuration by clicking the Sync Project with Gradle Files icon at the top of the window: 
If it cannot find the dependency, you should make sure you’ve specified `mavenCentral()` as a repository in `build.gradle`.
Next, add the following permissions in your AndroidManifest.xml:
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import com.mixpanel.android.mpmetrics.MixpanelAPI;
public class MainActivity extends ActionBarActivity {
private MixpanelAPI mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
trackAutomaticEvents = false;
// Replace with your Project Token
mp = MixpanelAPI.getInstance(this, "YOUR_TOKEN", trackAutomaticEvents);
}
}
##### Install the SDK
Add `https://github.com/mixpanel/mixpanel-unity.git#master` to the dependencies section of `com.mixpanel.unity`.
Alternatively, you can download and install the .unitypackage file from our [releases page](https://github.com/mixpanel/mixpanel-unity/releases)
.
##### Configure the SDK
To initialize the library, first open the unity project settings menu for Mixpanel. (Edit -> Project Settings -> Mixpanel) Then, enter your project token into the Token and Debug Token input fields within the inspector. You can find your token [here](https://mixpanel.com/settings/project)
.

Note: If you prefer to initialize Mixpanel manually, you can select the `Manual Initialization` in the settings and call `Mixpanel.Init()` to initialize.
To use mixpanel, add the following sample code to a part of your application:
using mixpanel;
You’re
##### Install the SDK
No install required
Using the HTTP API does not require an installation. **You’re ready to move to the next step.**
Integration / Framework Guides
==============================
[Segment](https://docs.mixpanel.com/docs/tracking-methods/integrations/segment)
[Google Tag Manager](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-tag-manager)
[Ad Spend](https://docs.mixpanel.com/docs/tracking-methods/integrations/ad-spend)
[Amazon S3](https://docs.mixpanel.com/docs/tracking-methods/integrations/amazon-s3)
[Amazon Kafka](https://docs.mixpanel.com/docs/tracking-methods/integrations/aws-kafka)
[CMS & E-Commerce](https://docs.mixpanel.com/docs/tracking-methods/integrations/cms-ecommerce)
[Customer.io](https://customer.io/docs/cdp/destinations/connections/mixpanel?utm_source=mixpanel&utm_medium=partner)
[Freshpaint](https://docs.mixpanel.com/docs/tracking-methods/integrations/freshpaint)
[Google Cloud Storage](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-cloud-storage)
[Google Pubsub](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-pubsub)
[Google Sheets](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-sheets)
[Langfuse](https://docs.mixpanel.com/docs/tracking-methods/integrations/langfuse)
[LaunchDarkly](https://docs.mixpanel.com/docs/tracking-methods/integrations/launchdarkly)
[mParticle](https://docs.mixpanel.com/docs/tracking-methods/integrations/mparticle)
[Next.js](https://docs.mixpanel.com/docs/tracking-methods/integrations/nextjs)
[Mobile Attribution Tracking](https://docs.mixpanel.com/docs/tracking-methods/integrations/mobile-attribution-tracking)
[Rudderstack](https://docs.mixpanel.com/docs/tracking-methods/integrations/rudderstack)
[Shopify](https://docs.mixpanel.com/docs/tracking-methods/integrations/shopify)
[Vendo for Shopify ↗](https://apps.shopify.com/vendo?utm_source=mixpanel&utm_medium=partner)
[Snowplow](https://docs.mixpanel.com/docs/tracking-methods/integrations/snowplow)
[Stripe](https://docs.mixpanel.com/docs/tracking-methods/integrations/stripe)
[Tealium](https://docs.mixpanel.com/docs/tracking-methods/integrations/tealium)
* * *
Next: Identify Your Users
-----------------------------
With Mixpanel installed, you’re now ready to identify the users who use your product.
Identify Your Users
FAQ[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=android#faq)
----------------------------------------------------------------------------------
**Does Mixpanel automatically track page views?**
Yes, if you pass `track_pageview: true` in the `mixpanel.init()` call, Mixpanel will automatically track a “Page View” event every time a new page is loaded. Learn more [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript#tracking-page-views)
.
**What are the recommended web configuration options?**
When tracking on web, we recommend using localStorage, as this is more reliable:
mixpanel.set_config({ persistence: "localStorage" });
Please note that cross-subdomain tracking is not possible when using local storage. If your implementation requires cross-subdomain tracking, remove the persistence flag and use the default “cookie” persistence option.
**Does Mixpanel use third-party cookies?**
No, our Mixpanel JavaScript SDK does not set or use any third-party cookies. If you wish to disable cookies entirely, you can set the disable\_persistence option to true when initializing your Mixpanel JS instance. Note that disabling persistence will disable the use of super properties and anonymous -> identified user tracking.
**How can I track in a privacy compliant way?**
If a user opts out of tracking, you can call the `.optOutTracking()` method on any of our client-side SDKs; this prevents any subsequent data being tracked from that user’s device. Learn more [here](https://docs.mixpanel.com/docs/privacy/protecting-user-data)
.
For iOS specifically: Mixpanel does not use IDFA, so it does not require user permission through the AppTrackingTransparency(ATT) framework. For more details, refer to our [Apple App Developer Privacy Guidance](https://mixpanel.com/legal/app-store-privacy-details)
.
[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
[Identify Users](https://docs.mixpanel.com/docs/quickstart/identify-users "Identify Users")
Was this page useful?
YesCould be better
---
# Install Mixpanel - Mixpanel Docs
Docs[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
Install Mixpanel
 Install Mixpanel
=======================================================================================================
Overview[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=ios#overview)
----------------------------------------------------------------------------------------
Installing Mixpanel is easy. This guide will show you how to do it with our SDKs.
Already collect product data? Connect your **[Data Warehouse](https://docs.mixpanel.com/docs/tracking-methods/warehouse-connectors)
** or via **[3rd Party Integrations](https://docs.mixpanel.com/docs/tracking-methods/integrations)
**.
Code[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=ios#code)
--------------------------------------------------------------------------------
Choose from the methods below. Not sure how to choose? [Read our guide](https://docs.mixpanel.com/docs/tracking-methods/choosing-the-right-method)
.
JavascriptPythonPHPNodeGoRubyJavaReact NativeFlutteriOS (Objective-C)iOS (Swift)AndroidUnityHTTP API
##### Install the SDK
snippetnpmyarn
npm install --save mixpanel-browser
yarn add mixpanel-browser
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
You can learn more about configuring Session Replay and Heatmaps [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript/javascript-replay)
.
//Import Mixpanel SDK
import mixpanel from "mixpanel-browser";
// Near entry of your product, init Mixpanel
mixpanel.init("YOUR_TOKEN", {
debug: true,
track_pageview: true,
persistence: "localStorage",
record_sessions_percent: 100, //records 100% of all sessions
record_heatmap_data: true,
});
##### Install the SDK
pip install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
from mixpanel import Mixpanel
mp = Mixpanel("YOUR_TOKEN")
##### Install the SDK
**Install with Composer**
1. Add mixpanel/mixpanel-php as a dependency and run composer update:
"require": {
...
"mixpanel/mixpanel-php" : "2.*"
...
}
**Install Manually**
1. [Download the Mixpanel PHP Library](https://github.com/mixpanel/mixpanel-php/archive/master.zip)
2. Extract the zip file to a directory called “mixpanel-php” in your project root
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
##### Install the SDK
npm install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
// Grab the Mixpanel factory
var Mixpanel = require("mixpanel");
// Create an instance of the mixpanel client
var mixpanel = Mixpanel.init("YOUR_TOKEN");
##### Install the SDK
go get github.com/mixpanel/mixpanel-go
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
package main
import (
"context"
"github.com/mixpanel/mixpanel-go"
)
func main() {
ctx := context.Background()
mp := mixpanel.NewApiClient("YOUR_TOKEN")
}
##### Install the SDK
gem install mixpanel-ruby
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
require 'mixpanel-ruby'
mp = Mixpanel::Tracker.new(YOUR_TOKEN)
##### Install the SDK
com.mixpanel
mixpanel-java
1.4.4
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import com.mixpanel.mixpanelapi.MessageBuilder;
import com.mixpanel.mixpanelapi.MixpanelAPI;
// Set up an instance of MixpanelAPI
MixpanelAPI mixpanel = new MixpanelAPI();
MessageBuilder messageBuilder = new MessageBuilder('YOUR_TOKEN');
##### Install the SDK
Under your app’s root directory, run:
npm install mixpanel-react-native
Under your application’s iOS folder, run:
pod install
Note: For XCode 12.5+, there is a known compile issue, please refer to this [workaround](https://github.com/mixpanel/mixpanel-react-native/issues/43#issuecomment-829599732)
.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import { Mixpanel } from "mixpanel-react-native";
// Set up an instance of Mixpanel
const trackAutomaticEvents = false;
const mixpanel = new Mixpanel("YOUR_TOKEN", trackAutomaticEvents);
mixpanel.init();
##### Install the SDK
Add `mixpanel_flutter: ^2.0.0` to your package’s pubspec.yaml file and run:
flutter pub get
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import 'package:mixpanel_flutter/mixpanel_flutter.dart';
class _YourClassState extends State {
Mixpanel mixpanel;
@override
void initState() {
super.initState();
initMixpanel();
}
Future initMixpanel() async {
// Once you've called this method once, you can access `mixpanel` throughout the rest of your application.
mixpanel = await Mixpanel.init("YOUR_TOKEN", trackAutomaticEvents: false);
}
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+ 1. In Xcode, select File > Swift Packages > Add Package Dependency. 2. Follow the prompts using the URL for this repository and must select a version greater than or equal to v4.0.0
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel'`. 2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-iphone"` to your Cartfile.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
#import "Mixpanel/Mixpanel.h"
- (BOOL)application:(UIApplication _)application
didFinishLaunchingWithOptions:(NSDictionary _)launchOptions {
...
Mixpanel \*mixpanel = [Mixpanel sharedInstanceWithToken:@"YOUR_TOKEN"\
trackAutomaticEvents: NO];
...
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+
1. In Xcode, select File > Swift Packages > Add Package Dependency.
2. Paste the URL `https://github.com/mixpanel/mixpanel-swift` and a minimum semantic version of v2.8.0.
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel-swift'`.
2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-swift"` to your Cartfile.
##### Configure the SDK
1. Import Mixpanel into `AppDelegate.swift`
2. Initialize Mixpanel within `application:didFinishLaunchingWithOptions` as seen below
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import Mixpanel
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
...
// Replace with your Project Token
Mixpanel.initialize(token: "YOUR_TOKEN", trackAutomaticEvents: false)
...
}
##### Install the SDK
Add `implementation 'com.mixpanel.android:mixpanel-android:7.+'` as a dependency to your `build.gradle` file.
Once you’ve updated `build.gradle`, you can force Android Studio to sync with your new configuration by clicking the Sync Project with Gradle Files icon at the top of the window: 
If it cannot find the dependency, you should make sure you’ve specified `mavenCentral()` as a repository in `build.gradle`.
Next, add the following permissions in your AndroidManifest.xml:
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import com.mixpanel.android.mpmetrics.MixpanelAPI;
public class MainActivity extends ActionBarActivity {
private MixpanelAPI mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
trackAutomaticEvents = false;
// Replace with your Project Token
mp = MixpanelAPI.getInstance(this, "YOUR_TOKEN", trackAutomaticEvents);
}
}
##### Install the SDK
Add `https://github.com/mixpanel/mixpanel-unity.git#master` to the dependencies section of `com.mixpanel.unity`.
Alternatively, you can download and install the .unitypackage file from our [releases page](https://github.com/mixpanel/mixpanel-unity/releases)
.
##### Configure the SDK
To initialize the library, first open the unity project settings menu for Mixpanel. (Edit -> Project Settings -> Mixpanel) Then, enter your project token into the Token and Debug Token input fields within the inspector. You can find your token [here](https://mixpanel.com/settings/project)
.

Note: If you prefer to initialize Mixpanel manually, you can select the `Manual Initialization` in the settings and call `Mixpanel.Init()` to initialize.
To use mixpanel, add the following sample code to a part of your application:
using mixpanel;
You’re
##### Install the SDK
No install required
Using the HTTP API does not require an installation. **You’re ready to move to the next step.**
Integration / Framework Guides
==============================
[Segment](https://docs.mixpanel.com/docs/tracking-methods/integrations/segment)
[Google Tag Manager](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-tag-manager)
[Ad Spend](https://docs.mixpanel.com/docs/tracking-methods/integrations/ad-spend)
[Amazon S3](https://docs.mixpanel.com/docs/tracking-methods/integrations/amazon-s3)
[Amazon Kafka](https://docs.mixpanel.com/docs/tracking-methods/integrations/aws-kafka)
[CMS & E-Commerce](https://docs.mixpanel.com/docs/tracking-methods/integrations/cms-ecommerce)
[Customer.io](https://customer.io/docs/cdp/destinations/connections/mixpanel?utm_source=mixpanel&utm_medium=partner)
[Freshpaint](https://docs.mixpanel.com/docs/tracking-methods/integrations/freshpaint)
[Google Cloud Storage](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-cloud-storage)
[Google Pubsub](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-pubsub)
[Google Sheets](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-sheets)
[Langfuse](https://docs.mixpanel.com/docs/tracking-methods/integrations/langfuse)
[LaunchDarkly](https://docs.mixpanel.com/docs/tracking-methods/integrations/launchdarkly)
[mParticle](https://docs.mixpanel.com/docs/tracking-methods/integrations/mparticle)
[Next.js](https://docs.mixpanel.com/docs/tracking-methods/integrations/nextjs)
[Mobile Attribution Tracking](https://docs.mixpanel.com/docs/tracking-methods/integrations/mobile-attribution-tracking)
[Rudderstack](https://docs.mixpanel.com/docs/tracking-methods/integrations/rudderstack)
[Shopify](https://docs.mixpanel.com/docs/tracking-methods/integrations/shopify)
[Vendo for Shopify ↗](https://apps.shopify.com/vendo?utm_source=mixpanel&utm_medium=partner)
[Snowplow](https://docs.mixpanel.com/docs/tracking-methods/integrations/snowplow)
[Stripe](https://docs.mixpanel.com/docs/tracking-methods/integrations/stripe)
[Tealium](https://docs.mixpanel.com/docs/tracking-methods/integrations/tealium)
* * *
Next: Identify Your Users
-----------------------------
With Mixpanel installed, you’re now ready to identify the users who use your product.
Identify Your Users
FAQ[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=ios#faq)
------------------------------------------------------------------------------
**Does Mixpanel automatically track page views?**
Yes, if you pass `track_pageview: true` in the `mixpanel.init()` call, Mixpanel will automatically track a “Page View” event every time a new page is loaded. Learn more [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript#tracking-page-views)
.
**What are the recommended web configuration options?**
When tracking on web, we recommend using localStorage, as this is more reliable:
mixpanel.set_config({ persistence: "localStorage" });
Please note that cross-subdomain tracking is not possible when using local storage. If your implementation requires cross-subdomain tracking, remove the persistence flag and use the default “cookie” persistence option.
**Does Mixpanel use third-party cookies?**
No, our Mixpanel JavaScript SDK does not set or use any third-party cookies. If you wish to disable cookies entirely, you can set the disable\_persistence option to true when initializing your Mixpanel JS instance. Note that disabling persistence will disable the use of super properties and anonymous -> identified user tracking.
**How can I track in a privacy compliant way?**
If a user opts out of tracking, you can call the `.optOutTracking()` method on any of our client-side SDKs; this prevents any subsequent data being tracked from that user’s device. Learn more [here](https://docs.mixpanel.com/docs/privacy/protecting-user-data)
.
For iOS specifically: Mixpanel does not use IDFA, so it does not require user permission through the AppTrackingTransparency(ATT) framework. For more details, refer to our [Apple App Developer Privacy Guidance](https://mixpanel.com/legal/app-store-privacy-details)
.
[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
[Identify Users](https://docs.mixpanel.com/docs/quickstart/identify-users "Identify Users")
Was this page useful?
YesCould be better
---
# Install Mixpanel - Mixpanel Docs
Docs[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
Install Mixpanel
 Install Mixpanel
=======================================================================================================
Overview[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=unity#overview)
------------------------------------------------------------------------------------------
Installing Mixpanel is easy. This guide will show you how to do it with our SDKs.
Already collect product data? Connect your **[Data Warehouse](https://docs.mixpanel.com/docs/tracking-methods/warehouse-connectors)
** or via **[3rd Party Integrations](https://docs.mixpanel.com/docs/tracking-methods/integrations)
**.
Code[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=unity#code)
----------------------------------------------------------------------------------
Choose from the methods below. Not sure how to choose? [Read our guide](https://docs.mixpanel.com/docs/tracking-methods/choosing-the-right-method)
.
JavascriptPythonPHPNodeGoRubyJavaReact NativeFlutteriOS (Objective-C)iOS (Swift)AndroidUnityHTTP API
##### Install the SDK
snippetnpmyarn
npm install --save mixpanel-browser
yarn add mixpanel-browser
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
You can learn more about configuring Session Replay and Heatmaps [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript/javascript-replay)
.
//Import Mixpanel SDK
import mixpanel from "mixpanel-browser";
// Near entry of your product, init Mixpanel
mixpanel.init("YOUR_TOKEN", {
debug: true,
track_pageview: true,
persistence: "localStorage",
record_sessions_percent: 100, //records 100% of all sessions
record_heatmap_data: true,
});
##### Install the SDK
pip install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
from mixpanel import Mixpanel
mp = Mixpanel("YOUR_TOKEN")
##### Install the SDK
**Install with Composer**
1. Add mixpanel/mixpanel-php as a dependency and run composer update:
"require": {
...
"mixpanel/mixpanel-php" : "2.*"
...
}
**Install Manually**
1. [Download the Mixpanel PHP Library](https://github.com/mixpanel/mixpanel-php/archive/master.zip)
2. Extract the zip file to a directory called “mixpanel-php” in your project root
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
##### Install the SDK
npm install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
// Grab the Mixpanel factory
var Mixpanel = require("mixpanel");
// Create an instance of the mixpanel client
var mixpanel = Mixpanel.init("YOUR_TOKEN");
##### Install the SDK
go get github.com/mixpanel/mixpanel-go
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
package main
import (
"context"
"github.com/mixpanel/mixpanel-go"
)
func main() {
ctx := context.Background()
mp := mixpanel.NewApiClient("YOUR_TOKEN")
}
##### Install the SDK
gem install mixpanel-ruby
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
require 'mixpanel-ruby'
mp = Mixpanel::Tracker.new(YOUR_TOKEN)
##### Install the SDK
com.mixpanel
mixpanel-java
1.4.4
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import com.mixpanel.mixpanelapi.MessageBuilder;
import com.mixpanel.mixpanelapi.MixpanelAPI;
// Set up an instance of MixpanelAPI
MixpanelAPI mixpanel = new MixpanelAPI();
MessageBuilder messageBuilder = new MessageBuilder('YOUR_TOKEN');
##### Install the SDK
Under your app’s root directory, run:
npm install mixpanel-react-native
Under your application’s iOS folder, run:
pod install
Note: For XCode 12.5+, there is a known compile issue, please refer to this [workaround](https://github.com/mixpanel/mixpanel-react-native/issues/43#issuecomment-829599732)
.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import { Mixpanel } from "mixpanel-react-native";
// Set up an instance of Mixpanel
const trackAutomaticEvents = false;
const mixpanel = new Mixpanel("YOUR_TOKEN", trackAutomaticEvents);
mixpanel.init();
##### Install the SDK
Add `mixpanel_flutter: ^2.0.0` to your package’s pubspec.yaml file and run:
flutter pub get
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import 'package:mixpanel_flutter/mixpanel_flutter.dart';
class _YourClassState extends State {
Mixpanel mixpanel;
@override
void initState() {
super.initState();
initMixpanel();
}
Future initMixpanel() async {
// Once you've called this method once, you can access `mixpanel` throughout the rest of your application.
mixpanel = await Mixpanel.init("YOUR_TOKEN", trackAutomaticEvents: false);
}
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+ 1. In Xcode, select File > Swift Packages > Add Package Dependency. 2. Follow the prompts using the URL for this repository and must select a version greater than or equal to v4.0.0
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel'`. 2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-iphone"` to your Cartfile.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
#import "Mixpanel/Mixpanel.h"
- (BOOL)application:(UIApplication _)application
didFinishLaunchingWithOptions:(NSDictionary _)launchOptions {
...
Mixpanel \*mixpanel = [Mixpanel sharedInstanceWithToken:@"YOUR_TOKEN"\
trackAutomaticEvents: NO];
...
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+
1. In Xcode, select File > Swift Packages > Add Package Dependency.
2. Paste the URL `https://github.com/mixpanel/mixpanel-swift` and a minimum semantic version of v2.8.0.
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel-swift'`.
2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-swift"` to your Cartfile.
##### Configure the SDK
1. Import Mixpanel into `AppDelegate.swift`
2. Initialize Mixpanel within `application:didFinishLaunchingWithOptions` as seen below
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import Mixpanel
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
...
// Replace with your Project Token
Mixpanel.initialize(token: "YOUR_TOKEN", trackAutomaticEvents: false)
...
}
##### Install the SDK
Add `implementation 'com.mixpanel.android:mixpanel-android:7.+'` as a dependency to your `build.gradle` file.
Once you’ve updated `build.gradle`, you can force Android Studio to sync with your new configuration by clicking the Sync Project with Gradle Files icon at the top of the window: 
If it cannot find the dependency, you should make sure you’ve specified `mavenCentral()` as a repository in `build.gradle`.
Next, add the following permissions in your AndroidManifest.xml:
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import com.mixpanel.android.mpmetrics.MixpanelAPI;
public class MainActivity extends ActionBarActivity {
private MixpanelAPI mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
trackAutomaticEvents = false;
// Replace with your Project Token
mp = MixpanelAPI.getInstance(this, "YOUR_TOKEN", trackAutomaticEvents);
}
}
##### Install the SDK
Add `https://github.com/mixpanel/mixpanel-unity.git#master` to the dependencies section of `com.mixpanel.unity`.
Alternatively, you can download and install the .unitypackage file from our [releases page](https://github.com/mixpanel/mixpanel-unity/releases)
.
##### Configure the SDK
To initialize the library, first open the unity project settings menu for Mixpanel. (Edit -> Project Settings -> Mixpanel) Then, enter your project token into the Token and Debug Token input fields within the inspector. You can find your token [here](https://mixpanel.com/settings/project)
.

Note: If you prefer to initialize Mixpanel manually, you can select the `Manual Initialization` in the settings and call `Mixpanel.Init()` to initialize.
To use mixpanel, add the following sample code to a part of your application:
using mixpanel;
You’re
##### Install the SDK
No install required
Using the HTTP API does not require an installation. **You’re ready to move to the next step.**
Integration / Framework Guides
==============================
[Segment](https://docs.mixpanel.com/docs/tracking-methods/integrations/segment)
[Google Tag Manager](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-tag-manager)
[Ad Spend](https://docs.mixpanel.com/docs/tracking-methods/integrations/ad-spend)
[Amazon S3](https://docs.mixpanel.com/docs/tracking-methods/integrations/amazon-s3)
[Amazon Kafka](https://docs.mixpanel.com/docs/tracking-methods/integrations/aws-kafka)
[CMS & E-Commerce](https://docs.mixpanel.com/docs/tracking-methods/integrations/cms-ecommerce)
[Customer.io](https://customer.io/docs/cdp/destinations/connections/mixpanel?utm_source=mixpanel&utm_medium=partner)
[Freshpaint](https://docs.mixpanel.com/docs/tracking-methods/integrations/freshpaint)
[Google Cloud Storage](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-cloud-storage)
[Google Pubsub](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-pubsub)
[Google Sheets](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-sheets)
[Langfuse](https://docs.mixpanel.com/docs/tracking-methods/integrations/langfuse)
[LaunchDarkly](https://docs.mixpanel.com/docs/tracking-methods/integrations/launchdarkly)
[mParticle](https://docs.mixpanel.com/docs/tracking-methods/integrations/mparticle)
[Next.js](https://docs.mixpanel.com/docs/tracking-methods/integrations/nextjs)
[Mobile Attribution Tracking](https://docs.mixpanel.com/docs/tracking-methods/integrations/mobile-attribution-tracking)
[Rudderstack](https://docs.mixpanel.com/docs/tracking-methods/integrations/rudderstack)
[Shopify](https://docs.mixpanel.com/docs/tracking-methods/integrations/shopify)
[Vendo for Shopify ↗](https://apps.shopify.com/vendo?utm_source=mixpanel&utm_medium=partner)
[Snowplow](https://docs.mixpanel.com/docs/tracking-methods/integrations/snowplow)
[Stripe](https://docs.mixpanel.com/docs/tracking-methods/integrations/stripe)
[Tealium](https://docs.mixpanel.com/docs/tracking-methods/integrations/tealium)
* * *
Next: Identify Your Users
-----------------------------
With Mixpanel installed, you’re now ready to identify the users who use your product.
Identify Your Users
FAQ[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=unity#faq)
--------------------------------------------------------------------------------
**Does Mixpanel automatically track page views?**
Yes, if you pass `track_pageview: true` in the `mixpanel.init()` call, Mixpanel will automatically track a “Page View” event every time a new page is loaded. Learn more [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript#tracking-page-views)
.
**What are the recommended web configuration options?**
When tracking on web, we recommend using localStorage, as this is more reliable:
mixpanel.set_config({ persistence: "localStorage" });
Please note that cross-subdomain tracking is not possible when using local storage. If your implementation requires cross-subdomain tracking, remove the persistence flag and use the default “cookie” persistence option.
**Does Mixpanel use third-party cookies?**
No, our Mixpanel JavaScript SDK does not set or use any third-party cookies. If you wish to disable cookies entirely, you can set the disable\_persistence option to true when initializing your Mixpanel JS instance. Note that disabling persistence will disable the use of super properties and anonymous -> identified user tracking.
**How can I track in a privacy compliant way?**
If a user opts out of tracking, you can call the `.optOutTracking()` method on any of our client-side SDKs; this prevents any subsequent data being tracked from that user’s device. Learn more [here](https://docs.mixpanel.com/docs/privacy/protecting-user-data)
.
For iOS specifically: Mixpanel does not use IDFA, so it does not require user permission through the AppTrackingTransparency(ATT) framework. For more details, refer to our [Apple App Developer Privacy Guidance](https://mixpanel.com/legal/app-store-privacy-details)
.
[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
[Identify Users](https://docs.mixpanel.com/docs/quickstart/identify-users "Identify Users")
Was this page useful?
YesCould be better
---
# Install Mixpanel - Mixpanel Docs
Docs[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
Install Mixpanel
 Install Mixpanel
=======================================================================================================
Overview[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=reactnative#overview)
------------------------------------------------------------------------------------------------
Installing Mixpanel is easy. This guide will show you how to do it with our SDKs.
Already collect product data? Connect your **[Data Warehouse](https://docs.mixpanel.com/docs/tracking-methods/warehouse-connectors)
** or via **[3rd Party Integrations](https://docs.mixpanel.com/docs/tracking-methods/integrations)
**.
Code[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=reactnative#code)
----------------------------------------------------------------------------------------
Choose from the methods below. Not sure how to choose? [Read our guide](https://docs.mixpanel.com/docs/tracking-methods/choosing-the-right-method)
.
JavascriptPythonPHPNodeGoRubyJavaReact NativeFlutteriOS (Objective-C)iOS (Swift)AndroidUnityHTTP API
##### Install the SDK
snippetnpmyarn
npm install --save mixpanel-browser
yarn add mixpanel-browser
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
You can learn more about configuring Session Replay and Heatmaps [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript/javascript-replay)
.
//Import Mixpanel SDK
import mixpanel from "mixpanel-browser";
// Near entry of your product, init Mixpanel
mixpanel.init("YOUR_TOKEN", {
debug: true,
track_pageview: true,
persistence: "localStorage",
record_sessions_percent: 100, //records 100% of all sessions
record_heatmap_data: true,
});
##### Install the SDK
pip install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
from mixpanel import Mixpanel
mp = Mixpanel("YOUR_TOKEN")
##### Install the SDK
**Install with Composer**
1. Add mixpanel/mixpanel-php as a dependency and run composer update:
"require": {
...
"mixpanel/mixpanel-php" : "2.*"
...
}
**Install Manually**
1. [Download the Mixpanel PHP Library](https://github.com/mixpanel/mixpanel-php/archive/master.zip)
2. Extract the zip file to a directory called “mixpanel-php” in your project root
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
##### Install the SDK
npm install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
// Grab the Mixpanel factory
var Mixpanel = require("mixpanel");
// Create an instance of the mixpanel client
var mixpanel = Mixpanel.init("YOUR_TOKEN");
##### Install the SDK
go get github.com/mixpanel/mixpanel-go
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
package main
import (
"context"
"github.com/mixpanel/mixpanel-go"
)
func main() {
ctx := context.Background()
mp := mixpanel.NewApiClient("YOUR_TOKEN")
}
##### Install the SDK
gem install mixpanel-ruby
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
require 'mixpanel-ruby'
mp = Mixpanel::Tracker.new(YOUR_TOKEN)
##### Install the SDK
com.mixpanel
mixpanel-java
1.4.4
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import com.mixpanel.mixpanelapi.MessageBuilder;
import com.mixpanel.mixpanelapi.MixpanelAPI;
// Set up an instance of MixpanelAPI
MixpanelAPI mixpanel = new MixpanelAPI();
MessageBuilder messageBuilder = new MessageBuilder('YOUR_TOKEN');
##### Install the SDK
Under your app’s root directory, run:
npm install mixpanel-react-native
Under your application’s iOS folder, run:
pod install
Note: For XCode 12.5+, there is a known compile issue, please refer to this [workaround](https://github.com/mixpanel/mixpanel-react-native/issues/43#issuecomment-829599732)
.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import { Mixpanel } from "mixpanel-react-native";
// Set up an instance of Mixpanel
const trackAutomaticEvents = false;
const mixpanel = new Mixpanel("YOUR_TOKEN", trackAutomaticEvents);
mixpanel.init();
##### Install the SDK
Add `mixpanel_flutter: ^2.0.0` to your package’s pubspec.yaml file and run:
flutter pub get
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import 'package:mixpanel_flutter/mixpanel_flutter.dart';
class _YourClassState extends State {
Mixpanel mixpanel;
@override
void initState() {
super.initState();
initMixpanel();
}
Future initMixpanel() async {
// Once you've called this method once, you can access `mixpanel` throughout the rest of your application.
mixpanel = await Mixpanel.init("YOUR_TOKEN", trackAutomaticEvents: false);
}
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+ 1. In Xcode, select File > Swift Packages > Add Package Dependency. 2. Follow the prompts using the URL for this repository and must select a version greater than or equal to v4.0.0
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel'`. 2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-iphone"` to your Cartfile.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
#import "Mixpanel/Mixpanel.h"
- (BOOL)application:(UIApplication _)application
didFinishLaunchingWithOptions:(NSDictionary _)launchOptions {
...
Mixpanel \*mixpanel = [Mixpanel sharedInstanceWithToken:@"YOUR_TOKEN"\
trackAutomaticEvents: NO];
...
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+
1. In Xcode, select File > Swift Packages > Add Package Dependency.
2. Paste the URL `https://github.com/mixpanel/mixpanel-swift` and a minimum semantic version of v2.8.0.
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel-swift'`.
2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-swift"` to your Cartfile.
##### Configure the SDK
1. Import Mixpanel into `AppDelegate.swift`
2. Initialize Mixpanel within `application:didFinishLaunchingWithOptions` as seen below
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import Mixpanel
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
...
// Replace with your Project Token
Mixpanel.initialize(token: "YOUR_TOKEN", trackAutomaticEvents: false)
...
}
##### Install the SDK
Add `implementation 'com.mixpanel.android:mixpanel-android:7.+'` as a dependency to your `build.gradle` file.
Once you’ve updated `build.gradle`, you can force Android Studio to sync with your new configuration by clicking the Sync Project with Gradle Files icon at the top of the window: 
If it cannot find the dependency, you should make sure you’ve specified `mavenCentral()` as a repository in `build.gradle`.
Next, add the following permissions in your AndroidManifest.xml:
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import com.mixpanel.android.mpmetrics.MixpanelAPI;
public class MainActivity extends ActionBarActivity {
private MixpanelAPI mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
trackAutomaticEvents = false;
// Replace with your Project Token
mp = MixpanelAPI.getInstance(this, "YOUR_TOKEN", trackAutomaticEvents);
}
}
##### Install the SDK
Add `https://github.com/mixpanel/mixpanel-unity.git#master` to the dependencies section of `com.mixpanel.unity`.
Alternatively, you can download and install the .unitypackage file from our [releases page](https://github.com/mixpanel/mixpanel-unity/releases)
.
##### Configure the SDK
To initialize the library, first open the unity project settings menu for Mixpanel. (Edit -> Project Settings -> Mixpanel) Then, enter your project token into the Token and Debug Token input fields within the inspector. You can find your token [here](https://mixpanel.com/settings/project)
.

Note: If you prefer to initialize Mixpanel manually, you can select the `Manual Initialization` in the settings and call `Mixpanel.Init()` to initialize.
To use mixpanel, add the following sample code to a part of your application:
using mixpanel;
You’re
##### Install the SDK
No install required
Using the HTTP API does not require an installation. **You’re ready to move to the next step.**
Integration / Framework Guides
==============================
[Segment](https://docs.mixpanel.com/docs/tracking-methods/integrations/segment)
[Google Tag Manager](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-tag-manager)
[Ad Spend](https://docs.mixpanel.com/docs/tracking-methods/integrations/ad-spend)
[Amazon S3](https://docs.mixpanel.com/docs/tracking-methods/integrations/amazon-s3)
[Amazon Kafka](https://docs.mixpanel.com/docs/tracking-methods/integrations/aws-kafka)
[CMS & E-Commerce](https://docs.mixpanel.com/docs/tracking-methods/integrations/cms-ecommerce)
[Customer.io](https://customer.io/docs/cdp/destinations/connections/mixpanel?utm_source=mixpanel&utm_medium=partner)
[Freshpaint](https://docs.mixpanel.com/docs/tracking-methods/integrations/freshpaint)
[Google Cloud Storage](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-cloud-storage)
[Google Pubsub](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-pubsub)
[Google Sheets](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-sheets)
[Langfuse](https://docs.mixpanel.com/docs/tracking-methods/integrations/langfuse)
[LaunchDarkly](https://docs.mixpanel.com/docs/tracking-methods/integrations/launchdarkly)
[mParticle](https://docs.mixpanel.com/docs/tracking-methods/integrations/mparticle)
[Next.js](https://docs.mixpanel.com/docs/tracking-methods/integrations/nextjs)
[Mobile Attribution Tracking](https://docs.mixpanel.com/docs/tracking-methods/integrations/mobile-attribution-tracking)
[Rudderstack](https://docs.mixpanel.com/docs/tracking-methods/integrations/rudderstack)
[Shopify](https://docs.mixpanel.com/docs/tracking-methods/integrations/shopify)
[Vendo for Shopify ↗](https://apps.shopify.com/vendo?utm_source=mixpanel&utm_medium=partner)
[Snowplow](https://docs.mixpanel.com/docs/tracking-methods/integrations/snowplow)
[Stripe](https://docs.mixpanel.com/docs/tracking-methods/integrations/stripe)
[Tealium](https://docs.mixpanel.com/docs/tracking-methods/integrations/tealium)
* * *
Next: Identify Your Users
-----------------------------
With Mixpanel installed, you’re now ready to identify the users who use your product.
Identify Your Users
FAQ[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=reactnative#faq)
--------------------------------------------------------------------------------------
**Does Mixpanel automatically track page views?**
Yes, if you pass `track_pageview: true` in the `mixpanel.init()` call, Mixpanel will automatically track a “Page View” event every time a new page is loaded. Learn more [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript#tracking-page-views)
.
**What are the recommended web configuration options?**
When tracking on web, we recommend using localStorage, as this is more reliable:
mixpanel.set_config({ persistence: "localStorage" });
Please note that cross-subdomain tracking is not possible when using local storage. If your implementation requires cross-subdomain tracking, remove the persistence flag and use the default “cookie” persistence option.
**Does Mixpanel use third-party cookies?**
No, our Mixpanel JavaScript SDK does not set or use any third-party cookies. If you wish to disable cookies entirely, you can set the disable\_persistence option to true when initializing your Mixpanel JS instance. Note that disabling persistence will disable the use of super properties and anonymous -> identified user tracking.
**How can I track in a privacy compliant way?**
If a user opts out of tracking, you can call the `.optOutTracking()` method on any of our client-side SDKs; this prevents any subsequent data being tracked from that user’s device. Learn more [here](https://docs.mixpanel.com/docs/privacy/protecting-user-data)
.
For iOS specifically: Mixpanel does not use IDFA, so it does not require user permission through the AppTrackingTransparency(ATT) framework. For more details, refer to our [Apple App Developer Privacy Guidance](https://mixpanel.com/legal/app-store-privacy-details)
.
[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
[Identify Users](https://docs.mixpanel.com/docs/quickstart/identify-users "Identify Users")
Was this page useful?
YesCould be better
---
# Install Mixpanel - Mixpanel Docs
Docs[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
Install Mixpanel
 Install Mixpanel
=======================================================================================================
Overview[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=flutter#overview)
--------------------------------------------------------------------------------------------
Installing Mixpanel is easy. This guide will show you how to do it with our SDKs.
Already collect product data? Connect your **[Data Warehouse](https://docs.mixpanel.com/docs/tracking-methods/warehouse-connectors)
** or via **[3rd Party Integrations](https://docs.mixpanel.com/docs/tracking-methods/integrations)
**.
Code[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=flutter#code)
------------------------------------------------------------------------------------
Choose from the methods below. Not sure how to choose? [Read our guide](https://docs.mixpanel.com/docs/tracking-methods/choosing-the-right-method)
.
JavascriptPythonPHPNodeGoRubyJavaReact NativeFlutteriOS (Objective-C)iOS (Swift)AndroidUnityHTTP API
##### Install the SDK
snippetnpmyarn
npm install --save mixpanel-browser
yarn add mixpanel-browser
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
You can learn more about configuring Session Replay and Heatmaps [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript/javascript-replay)
.
//Import Mixpanel SDK
import mixpanel from "mixpanel-browser";
// Near entry of your product, init Mixpanel
mixpanel.init("YOUR_TOKEN", {
debug: true,
track_pageview: true,
persistence: "localStorage",
record_sessions_percent: 100, //records 100% of all sessions
record_heatmap_data: true,
});
##### Install the SDK
pip install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
from mixpanel import Mixpanel
mp = Mixpanel("YOUR_TOKEN")
##### Install the SDK
**Install with Composer**
1. Add mixpanel/mixpanel-php as a dependency and run composer update:
"require": {
...
"mixpanel/mixpanel-php" : "2.*"
...
}
**Install Manually**
1. [Download the Mixpanel PHP Library](https://github.com/mixpanel/mixpanel-php/archive/master.zip)
2. Extract the zip file to a directory called “mixpanel-php” in your project root
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
##### Install the SDK
npm install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
// Grab the Mixpanel factory
var Mixpanel = require("mixpanel");
// Create an instance of the mixpanel client
var mixpanel = Mixpanel.init("YOUR_TOKEN");
##### Install the SDK
go get github.com/mixpanel/mixpanel-go
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
package main
import (
"context"
"github.com/mixpanel/mixpanel-go"
)
func main() {
ctx := context.Background()
mp := mixpanel.NewApiClient("YOUR_TOKEN")
}
##### Install the SDK
gem install mixpanel-ruby
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
require 'mixpanel-ruby'
mp = Mixpanel::Tracker.new(YOUR_TOKEN)
##### Install the SDK
com.mixpanel
mixpanel-java
1.4.4
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import com.mixpanel.mixpanelapi.MessageBuilder;
import com.mixpanel.mixpanelapi.MixpanelAPI;
// Set up an instance of MixpanelAPI
MixpanelAPI mixpanel = new MixpanelAPI();
MessageBuilder messageBuilder = new MessageBuilder('YOUR_TOKEN');
##### Install the SDK
Under your app’s root directory, run:
npm install mixpanel-react-native
Under your application’s iOS folder, run:
pod install
Note: For XCode 12.5+, there is a known compile issue, please refer to this [workaround](https://github.com/mixpanel/mixpanel-react-native/issues/43#issuecomment-829599732)
.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import { Mixpanel } from "mixpanel-react-native";
// Set up an instance of Mixpanel
const trackAutomaticEvents = false;
const mixpanel = new Mixpanel("YOUR_TOKEN", trackAutomaticEvents);
mixpanel.init();
##### Install the SDK
Add `mixpanel_flutter: ^2.0.0` to your package’s pubspec.yaml file and run:
flutter pub get
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import 'package:mixpanel_flutter/mixpanel_flutter.dart';
class _YourClassState extends State {
Mixpanel mixpanel;
@override
void initState() {
super.initState();
initMixpanel();
}
Future initMixpanel() async {
// Once you've called this method once, you can access `mixpanel` throughout the rest of your application.
mixpanel = await Mixpanel.init("YOUR_TOKEN", trackAutomaticEvents: false);
}
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+ 1. In Xcode, select File > Swift Packages > Add Package Dependency. 2. Follow the prompts using the URL for this repository and must select a version greater than or equal to v4.0.0
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel'`. 2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-iphone"` to your Cartfile.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
#import "Mixpanel/Mixpanel.h"
- (BOOL)application:(UIApplication _)application
didFinishLaunchingWithOptions:(NSDictionary _)launchOptions {
...
Mixpanel \*mixpanel = [Mixpanel sharedInstanceWithToken:@"YOUR_TOKEN"\
trackAutomaticEvents: NO];
...
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+
1. In Xcode, select File > Swift Packages > Add Package Dependency.
2. Paste the URL `https://github.com/mixpanel/mixpanel-swift` and a minimum semantic version of v2.8.0.
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel-swift'`.
2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-swift"` to your Cartfile.
##### Configure the SDK
1. Import Mixpanel into `AppDelegate.swift`
2. Initialize Mixpanel within `application:didFinishLaunchingWithOptions` as seen below
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import Mixpanel
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
...
// Replace with your Project Token
Mixpanel.initialize(token: "YOUR_TOKEN", trackAutomaticEvents: false)
...
}
##### Install the SDK
Add `implementation 'com.mixpanel.android:mixpanel-android:7.+'` as a dependency to your `build.gradle` file.
Once you’ve updated `build.gradle`, you can force Android Studio to sync with your new configuration by clicking the Sync Project with Gradle Files icon at the top of the window: 
If it cannot find the dependency, you should make sure you’ve specified `mavenCentral()` as a repository in `build.gradle`.
Next, add the following permissions in your AndroidManifest.xml:
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import com.mixpanel.android.mpmetrics.MixpanelAPI;
public class MainActivity extends ActionBarActivity {
private MixpanelAPI mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
trackAutomaticEvents = false;
// Replace with your Project Token
mp = MixpanelAPI.getInstance(this, "YOUR_TOKEN", trackAutomaticEvents);
}
}
##### Install the SDK
Add `https://github.com/mixpanel/mixpanel-unity.git#master` to the dependencies section of `com.mixpanel.unity`.
Alternatively, you can download and install the .unitypackage file from our [releases page](https://github.com/mixpanel/mixpanel-unity/releases)
.
##### Configure the SDK
To initialize the library, first open the unity project settings menu for Mixpanel. (Edit -> Project Settings -> Mixpanel) Then, enter your project token into the Token and Debug Token input fields within the inspector. You can find your token [here](https://mixpanel.com/settings/project)
.

Note: If you prefer to initialize Mixpanel manually, you can select the `Manual Initialization` in the settings and call `Mixpanel.Init()` to initialize.
To use mixpanel, add the following sample code to a part of your application:
using mixpanel;
You’re
##### Install the SDK
No install required
Using the HTTP API does not require an installation. **You’re ready to move to the next step.**
Integration / Framework Guides
==============================
[Segment](https://docs.mixpanel.com/docs/tracking-methods/integrations/segment)
[Google Tag Manager](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-tag-manager)
[Ad Spend](https://docs.mixpanel.com/docs/tracking-methods/integrations/ad-spend)
[Amazon S3](https://docs.mixpanel.com/docs/tracking-methods/integrations/amazon-s3)
[Amazon Kafka](https://docs.mixpanel.com/docs/tracking-methods/integrations/aws-kafka)
[CMS & E-Commerce](https://docs.mixpanel.com/docs/tracking-methods/integrations/cms-ecommerce)
[Customer.io](https://customer.io/docs/cdp/destinations/connections/mixpanel?utm_source=mixpanel&utm_medium=partner)
[Freshpaint](https://docs.mixpanel.com/docs/tracking-methods/integrations/freshpaint)
[Google Cloud Storage](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-cloud-storage)
[Google Pubsub](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-pubsub)
[Google Sheets](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-sheets)
[Langfuse](https://docs.mixpanel.com/docs/tracking-methods/integrations/langfuse)
[LaunchDarkly](https://docs.mixpanel.com/docs/tracking-methods/integrations/launchdarkly)
[mParticle](https://docs.mixpanel.com/docs/tracking-methods/integrations/mparticle)
[Next.js](https://docs.mixpanel.com/docs/tracking-methods/integrations/nextjs)
[Mobile Attribution Tracking](https://docs.mixpanel.com/docs/tracking-methods/integrations/mobile-attribution-tracking)
[Rudderstack](https://docs.mixpanel.com/docs/tracking-methods/integrations/rudderstack)
[Shopify](https://docs.mixpanel.com/docs/tracking-methods/integrations/shopify)
[Vendo for Shopify ↗](https://apps.shopify.com/vendo?utm_source=mixpanel&utm_medium=partner)
[Snowplow](https://docs.mixpanel.com/docs/tracking-methods/integrations/snowplow)
[Stripe](https://docs.mixpanel.com/docs/tracking-methods/integrations/stripe)
[Tealium](https://docs.mixpanel.com/docs/tracking-methods/integrations/tealium)
* * *
Next: Identify Your Users
-----------------------------
With Mixpanel installed, you’re now ready to identify the users who use your product.
Identify Your Users
FAQ[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=flutter#faq)
----------------------------------------------------------------------------------
**Does Mixpanel automatically track page views?**
Yes, if you pass `track_pageview: true` in the `mixpanel.init()` call, Mixpanel will automatically track a “Page View” event every time a new page is loaded. Learn more [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript#tracking-page-views)
.
**What are the recommended web configuration options?**
When tracking on web, we recommend using localStorage, as this is more reliable:
mixpanel.set_config({ persistence: "localStorage" });
Please note that cross-subdomain tracking is not possible when using local storage. If your implementation requires cross-subdomain tracking, remove the persistence flag and use the default “cookie” persistence option.
**Does Mixpanel use third-party cookies?**
No, our Mixpanel JavaScript SDK does not set or use any third-party cookies. If you wish to disable cookies entirely, you can set the disable\_persistence option to true when initializing your Mixpanel JS instance. Note that disabling persistence will disable the use of super properties and anonymous -> identified user tracking.
**How can I track in a privacy compliant way?**
If a user opts out of tracking, you can call the `.optOutTracking()` method on any of our client-side SDKs; this prevents any subsequent data being tracked from that user’s device. Learn more [here](https://docs.mixpanel.com/docs/privacy/protecting-user-data)
.
For iOS specifically: Mixpanel does not use IDFA, so it does not require user permission through the AppTrackingTransparency(ATT) framework. For more details, refer to our [Apple App Developer Privacy Guidance](https://mixpanel.com/legal/app-store-privacy-details)
.
[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
[Identify Users](https://docs.mixpanel.com/docs/quickstart/identify-users "Identify Users")
Was this page useful?
YesCould be better
---
# Install Mixpanel - Mixpanel Docs
Docs[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
Install Mixpanel
 Install Mixpanel
=======================================================================================================
Overview[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=httpapi#overview)
--------------------------------------------------------------------------------------------
Installing Mixpanel is easy. This guide will show you how to do it with our SDKs.
Already collect product data? Connect your **[Data Warehouse](https://docs.mixpanel.com/docs/tracking-methods/warehouse-connectors)
** or via **[3rd Party Integrations](https://docs.mixpanel.com/docs/tracking-methods/integrations)
**.
Code[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=httpapi#code)
------------------------------------------------------------------------------------
Choose from the methods below. Not sure how to choose? [Read our guide](https://docs.mixpanel.com/docs/tracking-methods/choosing-the-right-method)
.
JavascriptPythonPHPNodeGoRubyJavaReact NativeFlutteriOS (Objective-C)iOS (Swift)AndroidUnityHTTP API
##### Install the SDK
snippetnpmyarn
npm install --save mixpanel-browser
yarn add mixpanel-browser
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
You can learn more about configuring Session Replay and Heatmaps [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript/javascript-replay)
.
//Import Mixpanel SDK
import mixpanel from "mixpanel-browser";
// Near entry of your product, init Mixpanel
mixpanel.init("YOUR_TOKEN", {
debug: true,
track_pageview: true,
persistence: "localStorage",
record_sessions_percent: 100, //records 100% of all sessions
record_heatmap_data: true,
});
##### Install the SDK
pip install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
from mixpanel import Mixpanel
mp = Mixpanel("YOUR_TOKEN")
##### Install the SDK
**Install with Composer**
1. Add mixpanel/mixpanel-php as a dependency and run composer update:
"require": {
...
"mixpanel/mixpanel-php" : "2.*"
...
}
**Install Manually**
1. [Download the Mixpanel PHP Library](https://github.com/mixpanel/mixpanel-php/archive/master.zip)
2. Extract the zip file to a directory called “mixpanel-php” in your project root
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
##### Install the SDK
npm install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
// Grab the Mixpanel factory
var Mixpanel = require("mixpanel");
// Create an instance of the mixpanel client
var mixpanel = Mixpanel.init("YOUR_TOKEN");
##### Install the SDK
go get github.com/mixpanel/mixpanel-go
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
package main
import (
"context"
"github.com/mixpanel/mixpanel-go"
)
func main() {
ctx := context.Background()
mp := mixpanel.NewApiClient("YOUR_TOKEN")
}
##### Install the SDK
gem install mixpanel-ruby
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
require 'mixpanel-ruby'
mp = Mixpanel::Tracker.new(YOUR_TOKEN)
##### Install the SDK
com.mixpanel
mixpanel-java
1.4.4
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import com.mixpanel.mixpanelapi.MessageBuilder;
import com.mixpanel.mixpanelapi.MixpanelAPI;
// Set up an instance of MixpanelAPI
MixpanelAPI mixpanel = new MixpanelAPI();
MessageBuilder messageBuilder = new MessageBuilder('YOUR_TOKEN');
##### Install the SDK
Under your app’s root directory, run:
npm install mixpanel-react-native
Under your application’s iOS folder, run:
pod install
Note: For XCode 12.5+, there is a known compile issue, please refer to this [workaround](https://github.com/mixpanel/mixpanel-react-native/issues/43#issuecomment-829599732)
.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import { Mixpanel } from "mixpanel-react-native";
// Set up an instance of Mixpanel
const trackAutomaticEvents = false;
const mixpanel = new Mixpanel("YOUR_TOKEN", trackAutomaticEvents);
mixpanel.init();
##### Install the SDK
Add `mixpanel_flutter: ^2.0.0` to your package’s pubspec.yaml file and run:
flutter pub get
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import 'package:mixpanel_flutter/mixpanel_flutter.dart';
class _YourClassState extends State {
Mixpanel mixpanel;
@override
void initState() {
super.initState();
initMixpanel();
}
Future initMixpanel() async {
// Once you've called this method once, you can access `mixpanel` throughout the rest of your application.
mixpanel = await Mixpanel.init("YOUR_TOKEN", trackAutomaticEvents: false);
}
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+ 1. In Xcode, select File > Swift Packages > Add Package Dependency. 2. Follow the prompts using the URL for this repository and must select a version greater than or equal to v4.0.0
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel'`. 2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-iphone"` to your Cartfile.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
#import "Mixpanel/Mixpanel.h"
- (BOOL)application:(UIApplication _)application
didFinishLaunchingWithOptions:(NSDictionary _)launchOptions {
...
Mixpanel \*mixpanel = [Mixpanel sharedInstanceWithToken:@"YOUR_TOKEN"\
trackAutomaticEvents: NO];
...
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+
1. In Xcode, select File > Swift Packages > Add Package Dependency.
2. Paste the URL `https://github.com/mixpanel/mixpanel-swift` and a minimum semantic version of v2.8.0.
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel-swift'`.
2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-swift"` to your Cartfile.
##### Configure the SDK
1. Import Mixpanel into `AppDelegate.swift`
2. Initialize Mixpanel within `application:didFinishLaunchingWithOptions` as seen below
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import Mixpanel
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
...
// Replace with your Project Token
Mixpanel.initialize(token: "YOUR_TOKEN", trackAutomaticEvents: false)
...
}
##### Install the SDK
Add `implementation 'com.mixpanel.android:mixpanel-android:7.+'` as a dependency to your `build.gradle` file.
Once you’ve updated `build.gradle`, you can force Android Studio to sync with your new configuration by clicking the Sync Project with Gradle Files icon at the top of the window: 
If it cannot find the dependency, you should make sure you’ve specified `mavenCentral()` as a repository in `build.gradle`.
Next, add the following permissions in your AndroidManifest.xml:
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import com.mixpanel.android.mpmetrics.MixpanelAPI;
public class MainActivity extends ActionBarActivity {
private MixpanelAPI mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
trackAutomaticEvents = false;
// Replace with your Project Token
mp = MixpanelAPI.getInstance(this, "YOUR_TOKEN", trackAutomaticEvents);
}
}
##### Install the SDK
Add `https://github.com/mixpanel/mixpanel-unity.git#master` to the dependencies section of `com.mixpanel.unity`.
Alternatively, you can download and install the .unitypackage file from our [releases page](https://github.com/mixpanel/mixpanel-unity/releases)
.
##### Configure the SDK
To initialize the library, first open the unity project settings menu for Mixpanel. (Edit -> Project Settings -> Mixpanel) Then, enter your project token into the Token and Debug Token input fields within the inspector. You can find your token [here](https://mixpanel.com/settings/project)
.

Note: If you prefer to initialize Mixpanel manually, you can select the `Manual Initialization` in the settings and call `Mixpanel.Init()` to initialize.
To use mixpanel, add the following sample code to a part of your application:
using mixpanel;
You’re
##### Install the SDK
No install required
Using the HTTP API does not require an installation. **You’re ready to move to the next step.**
Integration / Framework Guides
==============================
[Segment](https://docs.mixpanel.com/docs/tracking-methods/integrations/segment)
[Google Tag Manager](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-tag-manager)
[Ad Spend](https://docs.mixpanel.com/docs/tracking-methods/integrations/ad-spend)
[Amazon S3](https://docs.mixpanel.com/docs/tracking-methods/integrations/amazon-s3)
[Amazon Kafka](https://docs.mixpanel.com/docs/tracking-methods/integrations/aws-kafka)
[CMS & E-Commerce](https://docs.mixpanel.com/docs/tracking-methods/integrations/cms-ecommerce)
[Customer.io](https://customer.io/docs/cdp/destinations/connections/mixpanel?utm_source=mixpanel&utm_medium=partner)
[Freshpaint](https://docs.mixpanel.com/docs/tracking-methods/integrations/freshpaint)
[Google Cloud Storage](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-cloud-storage)
[Google Pubsub](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-pubsub)
[Google Sheets](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-sheets)
[Langfuse](https://docs.mixpanel.com/docs/tracking-methods/integrations/langfuse)
[LaunchDarkly](https://docs.mixpanel.com/docs/tracking-methods/integrations/launchdarkly)
[mParticle](https://docs.mixpanel.com/docs/tracking-methods/integrations/mparticle)
[Next.js](https://docs.mixpanel.com/docs/tracking-methods/integrations/nextjs)
[Mobile Attribution Tracking](https://docs.mixpanel.com/docs/tracking-methods/integrations/mobile-attribution-tracking)
[Rudderstack](https://docs.mixpanel.com/docs/tracking-methods/integrations/rudderstack)
[Shopify](https://docs.mixpanel.com/docs/tracking-methods/integrations/shopify)
[Vendo for Shopify ↗](https://apps.shopify.com/vendo?utm_source=mixpanel&utm_medium=partner)
[Snowplow](https://docs.mixpanel.com/docs/tracking-methods/integrations/snowplow)
[Stripe](https://docs.mixpanel.com/docs/tracking-methods/integrations/stripe)
[Tealium](https://docs.mixpanel.com/docs/tracking-methods/integrations/tealium)
* * *
Next: Identify Your Users
-----------------------------
With Mixpanel installed, you’re now ready to identify the users who use your product.
Identify Your Users
FAQ[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=httpapi#faq)
----------------------------------------------------------------------------------
**Does Mixpanel automatically track page views?**
Yes, if you pass `track_pageview: true` in the `mixpanel.init()` call, Mixpanel will automatically track a “Page View” event every time a new page is loaded. Learn more [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript#tracking-page-views)
.
**What are the recommended web configuration options?**
When tracking on web, we recommend using localStorage, as this is more reliable:
mixpanel.set_config({ persistence: "localStorage" });
Please note that cross-subdomain tracking is not possible when using local storage. If your implementation requires cross-subdomain tracking, remove the persistence flag and use the default “cookie” persistence option.
**Does Mixpanel use third-party cookies?**
No, our Mixpanel JavaScript SDK does not set or use any third-party cookies. If you wish to disable cookies entirely, you can set the disable\_persistence option to true when initializing your Mixpanel JS instance. Note that disabling persistence will disable the use of super properties and anonymous -> identified user tracking.
**How can I track in a privacy compliant way?**
If a user opts out of tracking, you can call the `.optOutTracking()` method on any of our client-side SDKs; this prevents any subsequent data being tracked from that user’s device. Learn more [here](https://docs.mixpanel.com/docs/privacy/protecting-user-data)
.
For iOS specifically: Mixpanel does not use IDFA, so it does not require user permission through the AppTrackingTransparency(ATT) framework. For more details, refer to our [Apple App Developer Privacy Guidance](https://mixpanel.com/legal/app-store-privacy-details)
.
[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
[Identify Users](https://docs.mixpanel.com/docs/quickstart/identify-users "Identify Users")
Was this page useful?
YesCould be better
---
# Install Mixpanel - Mixpanel Docs
Docs[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
Install Mixpanel
 Install Mixpanel
=======================================================================================================
Overview[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=python#overview)
-------------------------------------------------------------------------------------------
Installing Mixpanel is easy. This guide will show you how to do it with our SDKs.
Already collect product data? Connect your **[Data Warehouse](https://docs.mixpanel.com/docs/tracking-methods/warehouse-connectors)
** or via **[3rd Party Integrations](https://docs.mixpanel.com/docs/tracking-methods/integrations)
**.
Code[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=python#code)
-----------------------------------------------------------------------------------
Choose from the methods below. Not sure how to choose? [Read our guide](https://docs.mixpanel.com/docs/tracking-methods/choosing-the-right-method)
.
JavascriptPythonPHPNodeGoRubyJavaReact NativeFlutteriOS (Objective-C)iOS (Swift)AndroidUnityHTTP API
##### Install the SDK
snippetnpmyarn
npm install --save mixpanel-browser
yarn add mixpanel-browser
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
You can learn more about configuring Session Replay and Heatmaps [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript/javascript-replay)
.
//Import Mixpanel SDK
import mixpanel from "mixpanel-browser";
// Near entry of your product, init Mixpanel
mixpanel.init("YOUR_TOKEN", {
debug: true,
track_pageview: true,
persistence: "localStorage",
record_sessions_percent: 100, //records 100% of all sessions
record_heatmap_data: true,
});
##### Install the SDK
pip install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
from mixpanel import Mixpanel
mp = Mixpanel("YOUR_TOKEN")
##### Install the SDK
**Install with Composer**
1. Add mixpanel/mixpanel-php as a dependency and run composer update:
"require": {
...
"mixpanel/mixpanel-php" : "2.*"
...
}
**Install Manually**
1. [Download the Mixpanel PHP Library](https://github.com/mixpanel/mixpanel-php/archive/master.zip)
2. Extract the zip file to a directory called “mixpanel-php” in your project root
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
##### Install the SDK
npm install mixpanel
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
// Grab the Mixpanel factory
var Mixpanel = require("mixpanel");
// Create an instance of the mixpanel client
var mixpanel = Mixpanel.init("YOUR_TOKEN");
##### Install the SDK
go get github.com/mixpanel/mixpanel-go
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
package main
import (
"context"
"github.com/mixpanel/mixpanel-go"
)
func main() {
ctx := context.Background()
mp := mixpanel.NewApiClient("YOUR_TOKEN")
}
##### Install the SDK
gem install mixpanel-ruby
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
require 'mixpanel-ruby'
mp = Mixpanel::Tracker.new(YOUR_TOKEN)
##### Install the SDK
com.mixpanel
mixpanel-java
1.4.4
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import com.mixpanel.mixpanelapi.MessageBuilder;
import com.mixpanel.mixpanelapi.MixpanelAPI;
// Set up an instance of MixpanelAPI
MixpanelAPI mixpanel = new MixpanelAPI();
MessageBuilder messageBuilder = new MessageBuilder('YOUR_TOKEN');
##### Install the SDK
Under your app’s root directory, run:
npm install mixpanel-react-native
Under your application’s iOS folder, run:
pod install
Note: For XCode 12.5+, there is a known compile issue, please refer to this [workaround](https://github.com/mixpanel/mixpanel-react-native/issues/43#issuecomment-829599732)
.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
//Import Mixpanel API
import { Mixpanel } from "mixpanel-react-native";
// Set up an instance of Mixpanel
const trackAutomaticEvents = false;
const mixpanel = new Mixpanel("YOUR_TOKEN", trackAutomaticEvents);
mixpanel.init();
##### Install the SDK
Add `mixpanel_flutter: ^2.0.0` to your package’s pubspec.yaml file and run:
flutter pub get
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import 'package:mixpanel_flutter/mixpanel_flutter.dart';
class _YourClassState extends State {
Mixpanel mixpanel;
@override
void initState() {
super.initState();
initMixpanel();
}
Future initMixpanel() async {
// Once you've called this method once, you can access `mixpanel` throughout the rest of your application.
mixpanel = await Mixpanel.init("YOUR_TOKEN", trackAutomaticEvents: false);
}
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+ 1. In Xcode, select File > Swift Packages > Add Package Dependency. 2. Follow the prompts using the URL for this repository and must select a version greater than or equal to v4.0.0
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel'`. 2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-iphone"` to your Cartfile.
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
#import "Mixpanel/Mixpanel.h"
- (BOOL)application:(UIApplication _)application
didFinishLaunchingWithOptions:(NSDictionary _)launchOptions {
...
Mixpanel \*mixpanel = [Mixpanel sharedInstanceWithToken:@"YOUR_TOKEN"\
trackAutomaticEvents: NO];
...
}
##### Install the SDK
Swift Package ManagerCocoapodsCarthage
Note: Swift Package Manager requires Xcode 12+
1. In Xcode, select File > Swift Packages > Add Package Dependency.
2. Paste the URL `https://github.com/mixpanel/mixpanel-swift` and a minimum semantic version of v2.8.0.
1. Create a Podfile in your Xcode project directory by running `pod init` in your terminal, edit the Podfile generated, and add the following line: `pod 'Mixpanel-swift'`.
2. Run `pod install` in your Xcode project directory. CocoaPods should download and install the Mixpanel library, and create a new Xcode workspace. Open up this workspace in Xcode or typing `open *.xcworkspace` in your terminal.
Add `github "mixpanel/mixpanel-swift"` to your Cartfile.
##### Configure the SDK
1. Import Mixpanel into `AppDelegate.swift`
2. Initialize Mixpanel within `application:didFinishLaunchingWithOptions` as seen below
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import Mixpanel
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
...
// Replace with your Project Token
Mixpanel.initialize(token: "YOUR_TOKEN", trackAutomaticEvents: false)
...
}
##### Install the SDK
Add `implementation 'com.mixpanel.android:mixpanel-android:7.+'` as a dependency to your `build.gradle` file.
Once you’ve updated `build.gradle`, you can force Android Studio to sync with your new configuration by clicking the Sync Project with Gradle Files icon at the top of the window: 
If it cannot find the dependency, you should make sure you’ve specified `mavenCentral()` as a repository in `build.gradle`.
Next, add the following permissions in your AndroidManifest.xml:
##### Configure the SDK
Replace `YOUR_TOKEN` with your project token. You can find your token [here](https://mixpanel.com/settings/project)
.
import com.mixpanel.android.mpmetrics.MixpanelAPI;
public class MainActivity extends ActionBarActivity {
private MixpanelAPI mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
trackAutomaticEvents = false;
// Replace with your Project Token
mp = MixpanelAPI.getInstance(this, "YOUR_TOKEN", trackAutomaticEvents);
}
}
##### Install the SDK
Add `https://github.com/mixpanel/mixpanel-unity.git#master` to the dependencies section of `com.mixpanel.unity`.
Alternatively, you can download and install the .unitypackage file from our [releases page](https://github.com/mixpanel/mixpanel-unity/releases)
.
##### Configure the SDK
To initialize the library, first open the unity project settings menu for Mixpanel. (Edit -> Project Settings -> Mixpanel) Then, enter your project token into the Token and Debug Token input fields within the inspector. You can find your token [here](https://mixpanel.com/settings/project)
.

Note: If you prefer to initialize Mixpanel manually, you can select the `Manual Initialization` in the settings and call `Mixpanel.Init()` to initialize.
To use mixpanel, add the following sample code to a part of your application:
using mixpanel;
You’re
##### Install the SDK
No install required
Using the HTTP API does not require an installation. **You’re ready to move to the next step.**
Integration / Framework Guides
==============================
[Segment](https://docs.mixpanel.com/docs/tracking-methods/integrations/segment)
[Google Tag Manager](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-tag-manager)
[Ad Spend](https://docs.mixpanel.com/docs/tracking-methods/integrations/ad-spend)
[Amazon S3](https://docs.mixpanel.com/docs/tracking-methods/integrations/amazon-s3)
[Amazon Kafka](https://docs.mixpanel.com/docs/tracking-methods/integrations/aws-kafka)
[CMS & E-Commerce](https://docs.mixpanel.com/docs/tracking-methods/integrations/cms-ecommerce)
[Customer.io](https://customer.io/docs/cdp/destinations/connections/mixpanel?utm_source=mixpanel&utm_medium=partner)
[Freshpaint](https://docs.mixpanel.com/docs/tracking-methods/integrations/freshpaint)
[Google Cloud Storage](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-cloud-storage)
[Google Pubsub](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-pubsub)
[Google Sheets](https://docs.mixpanel.com/docs/tracking-methods/integrations/google-sheets)
[Langfuse](https://docs.mixpanel.com/docs/tracking-methods/integrations/langfuse)
[LaunchDarkly](https://docs.mixpanel.com/docs/tracking-methods/integrations/launchdarkly)
[mParticle](https://docs.mixpanel.com/docs/tracking-methods/integrations/mparticle)
[Next.js](https://docs.mixpanel.com/docs/tracking-methods/integrations/nextjs)
[Mobile Attribution Tracking](https://docs.mixpanel.com/docs/tracking-methods/integrations/mobile-attribution-tracking)
[Rudderstack](https://docs.mixpanel.com/docs/tracking-methods/integrations/rudderstack)
[Shopify](https://docs.mixpanel.com/docs/tracking-methods/integrations/shopify)
[Vendo for Shopify ↗](https://apps.shopify.com/vendo?utm_source=mixpanel&utm_medium=partner)
[Snowplow](https://docs.mixpanel.com/docs/tracking-methods/integrations/snowplow)
[Stripe](https://docs.mixpanel.com/docs/tracking-methods/integrations/stripe)
[Tealium](https://docs.mixpanel.com/docs/tracking-methods/integrations/tealium)
* * *
Next: Identify Your Users
-----------------------------
With Mixpanel installed, you’re now ready to identify the users who use your product.
Identify Your Users
FAQ[](https://docs.mixpanel.com/docs/quickstart/install-mixpanel?sdk=python#faq)
---------------------------------------------------------------------------------
**Does Mixpanel automatically track page views?**
Yes, if you pass `track_pageview: true` in the `mixpanel.init()` call, Mixpanel will automatically track a “Page View” event every time a new page is loaded. Learn more [here](https://docs.mixpanel.com/docs/tracking-methods/sdks/javascript#tracking-page-views)
.
**What are the recommended web configuration options?**
When tracking on web, we recommend using localStorage, as this is more reliable:
mixpanel.set_config({ persistence: "localStorage" });
Please note that cross-subdomain tracking is not possible when using local storage. If your implementation requires cross-subdomain tracking, remove the persistence flag and use the default “cookie” persistence option.
**Does Mixpanel use third-party cookies?**
No, our Mixpanel JavaScript SDK does not set or use any third-party cookies. If you wish to disable cookies entirely, you can set the disable\_persistence option to true when initializing your Mixpanel JS instance. Note that disabling persistence will disable the use of super properties and anonymous -> identified user tracking.
**How can I track in a privacy compliant way?**
If a user opts out of tracking, you can call the `.optOutTracking()` method on any of our client-side SDKs; this prevents any subsequent data being tracked from that user’s device. Learn more [here](https://docs.mixpanel.com/docs/privacy/protecting-user-data)
.
For iOS specifically: Mixpanel does not use IDFA, so it does not require user permission through the AppTrackingTransparency(ATT) framework. For more details, refer to our [Apple App Developer Privacy Guidance](https://mixpanel.com/legal/app-store-privacy-details)
.
[Quickstart](https://docs.mixpanel.com/docs/quickstart "Quickstart")
[Identify Users](https://docs.mixpanel.com/docs/quickstart/identify-users "Identify Users")
Was this page useful?
YesCould be better
---