> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/mixpanel/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# SDKs

> Native libraries to send data from your application into Mixpanel

# SDKs: Send Data from Your Application

Our SDKs allow you to implement Mixpanel in a wide range of environments. Visit our [Github repo](https://mixpanel.com/partners/integrations) to see the library source code.

If you do not see an SDK in your preferred language, leverage our [HTTP APIs](https://developer.mixpanel.com/reference/ingestion-api) directly.

## Client-Side SDKs

Client-side SDKs run in the user's browser or on their mobile device, making it easy to track user interactions and automatically capture device information.

<CardGroup cols={2}>
  <Card title="Javascript" icon="js" href="/docs/tracking-methods/sdks/javascript">
    Track events in web browsers with autocapture and session replay
  </Card>

  <Card title="React Native" icon="react" href="/docs/tracking-methods/sdks/react-native">
    Cross-platform mobile tracking for React Native apps
  </Card>

  <Card title="Android" icon="android" href="/docs/tracking-methods/sdks/android">
    Native Android SDK with replay and feature flags
  </Card>

  <Card title="iOS (Objective-C)" icon="apple" href="/docs/tracking-methods/sdks/ios">
    Legacy iOS SDK for Objective-C apps
  </Card>

  <Card title="iOS (Swift)" icon="swift" href="/docs/tracking-methods/sdks/swift">
    Modern Swift SDK with replay and feature flags
  </Card>

  <Card title="Flutter" icon="flutter" href="/docs/tracking-methods/sdks/flutter">
    Cross-platform tracking for Flutter applications
  </Card>

  <Card title="Unity" icon="gamepad" href="/docs/tracking-methods/sdks/unity">
    Game analytics for Unity game engine
  </Card>
</CardGroup>

### JavaScript SDK Quick Start

The easiest way to get started with web tracking:

```html theme={null}
<!-- Paste this right before your closing head tag -->
<script type="text/javascript">
(function (f, b) { if (!b.__SV) { var e, g, i, h; window.mixpanel = b; b._i = []; b.init = function (e, f, c) { function g(a, d) { var b = d.split("."); 2 == b.length && ((a = a[b[0]]), (d = b[1])); a[d] = function () { a.push([d].concat(Array.prototype.slice.call(arguments, 0))); }; } var a = b; "undefined" !== typeof c ? (a = b[c] = []) : (c = "mixpanel"); a.people = a.people || []; a.toString = function (a) { var d = "mixpanel"; "mixpanel" !== c && (d += "." + c); a || (d += " (stub)"); return d; }; a.people.toString = function () { return a.toString(1) + ".people (stub)"; }; i = "disable time_event track track_pageview track_links track_forms track_with_groups add_group set_group remove_group register register_once alias unregister identify name_tag set_config reset opt_in_tracking opt_out_tracking has_opted_in_tracking has_opted_out_tracking clear_opt_in_out_tracking start_batch_senders people.set people.set_once people.unset people.increment people.append people.union people.track_charge people.clear_charges people.delete_user people.remove".split(" "); for (h = 0; h < i.length; h++) g(a, i[h]); var j = "set set_once union unset remove delete".split(" "); a.get_group = function () { function b(c) { d[c] = function () { call2_args = arguments; call2 = [c].concat(Array.prototype.slice.call(call2_args, 0)); a.push([e, call2]); }; } for (var d = {}, e = ["get_group"].concat(Array.prototype.slice.call(arguments, 0)), c = 0; c < j.length; c++) b(j[c]); return d; }; b._i.push([e, f, c]); }; b.__SV = 1.2; e = f.createElement("script"); e.type = "text/javascript"; e.async = !0; e.src = "undefined" !== typeof MIXPANEL_CUSTOM_LIB_URL ? MIXPANEL_CUSTOM_LIB_URL : "file:" === f.location.protocol && "//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//) ? "https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js" : "//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js"; g = f.getElementsByTagName("script")[0]; g.parentNode.insertBefore(e, g); } })(document, window.mixpanel || []);

// Initialize Mixpanel
mixpanel.init("YOUR_PROJECT_TOKEN", {
    autocapture: true,
    track_pageview: true,
    record_sessions_percent: 100,
    record_heatmap_data: true,
});
</script>
```

Or install via NPM:

```bash theme={null}
npm install --save mixpanel-browser
```

```javascript theme={null}
import mixpanel from 'mixpanel-browser'

mixpanel.init("YOUR_PROJECT_TOKEN", {
    autocapture: true,
    track_pageview: true,
});

// Track an event
mixpanel.track('Button Clicked', {
    'button_name': 'Sign Up',
    'page': 'Homepage'
});
```

## Server-Side SDKs

Server-side SDKs are designed for backend environments where you have full control over the tracking logic. These SDKs are more reliable and not affected by ad-blockers.

<CardGroup cols={2}>
  <Card title="Python" icon="python" href="/docs/tracking-methods/sdks/python">
    Server-side tracking for Python applications
  </Card>

  <Card title="Node.js" icon="node" href="/docs/tracking-methods/sdks/nodejs">
    Async JavaScript tracking for Node.js servers
  </Card>

  <Card title="Ruby" icon="gem" href="/docs/tracking-methods/sdks/ruby">
    Server-side tracking for Ruby applications
  </Card>

  <Card title="PHP" icon="php" href="/docs/tracking-methods/sdks/php">
    Server-side tracking for PHP applications
  </Card>

  <Card title="Go" icon="golang" href="/docs/tracking-methods/sdks/go">
    High-performance tracking for Go applications
  </Card>

  <Card title="Java" icon="java" href="/docs/tracking-methods/sdks/java">
    Enterprise-grade tracking for Java applications
  </Card>
</CardGroup>

### Python SDK Quick Start

```bash theme={null}
pip install mixpanel
```

```python theme={null}
from mixpanel import Mixpanel

# Initialize Mixpanel
mp = Mixpanel("YOUR_PROJECT_TOKEN")

# Track an event
mp.track('12345', 'Sign Up', {
    'plan': 'premium',
    'source': 'landing_page'
})

# Set user profile properties
mp.people_set('12345', {
    'name': 'Sam Smith',
    '$email': 'sam@example.com',
}, meta={'$ip': 0})
```

### Node.js SDK Quick Start

```bash theme={null}
npm install mixpanel
```

```javascript theme={null}
const Mixpanel = require('mixpanel');

// Initialize Mixpanel
const mp = Mixpanel.init('YOUR_PROJECT_TOKEN');

// Track an event
mp.track('Sign Up', {
    distinct_id: '12345',
    plan: 'premium',
    source: 'landing_page'
});

// Set user profile properties
mp.people.set('12345', {
    'name': 'Sam Smith',
    '$email': 'sam@example.com'
});
```

## Session Replay SDKs

Capture user sessions with video-like replay capabilities to understand exactly how users interact with your product.

<CardGroup cols={2}>
  <Card title="Android Replay" icon="video" href="/docs/tracking-methods/sdks/android/android-replay">
    Record and replay Android user sessions
  </Card>

  <Card title="Swift Replay" icon="video" href="/docs/tracking-methods/sdks/swift/swift-replay">
    Record and replay iOS user sessions
  </Card>

  <Card title="JavaScript Replay" icon="video" href="/docs/tracking-methods/sdks/javascript/javascript-replay">
    Record and replay web user sessions
  </Card>

  <Card title="React Native Replay" icon="video" href="/docs/tracking-methods/sdks/react-native/react-native-replay">
    Record and replay React Native sessions
  </Card>
</CardGroup>

## SDK Features

<AccordionGroup>
  <Accordion title="Event Tracking">
    All SDKs support tracking custom events with properties. Events capture user actions and important moments in your product.

    ```python theme={null}
    # Python example
    mp.track('distinct_id', 'Video Watched', {
        'video_title': 'Getting Started',
        'duration': 120,
        'completion_rate': 0.85
    })
    ```
  </Accordion>

  <Accordion title="User Profiles">
    Store demographic and behavioral data about your users with profile properties.

    ```javascript theme={null}
    // JavaScript example
    mixpanel.people.set({
        '$name': 'Jane Doe',
        '$email': 'jane@example.com',
        'plan_type': 'enterprise'
    });
    ```
  </Accordion>

  <Accordion title="Identity Management">
    Link anonymous users to identified users as they sign up or log in.

    ```javascript theme={null}
    // Track anonymous user
    mixpanel.track('Page Viewed');

    // User signs up - identify them
    mixpanel.identify('user_123');

    // Now all future events are tied to user_123
    mixpanel.track('Button Clicked');
    ```
  </Accordion>

  <Accordion title="Group Analytics">
    Analyze behavior at the account or company level with group analytics.

    ```python theme={null}
    # Set group for an event
    mp.track('user_123', 'Feature Used', {
        '$groups': {'company': 'acme_inc'}
    })

    # Set group properties
    mp.get_group('company', 'acme_inc').set({
        'plan': 'enterprise',
        'industry': 'technology'
    })
    ```
  </Accordion>

  <Accordion title="Autocapture (Web & Mobile)">
    Automatically track clicks, page views, and form submissions without writing code.

    ```javascript theme={null}
    mixpanel.init('YOUR_PROJECT_TOKEN', {
        autocapture: {
            pageview: 'full-url',
            click: true,
            submit: true,
            input: true,
            scroll: true
        }
    });
    ```
  </Accordion>
</AccordionGroup>

## API Endpoints by Data Residency

Ensure you configure your SDK to use the correct API host based on your project's data residency:

| Data Residency | API Host              | Configuration                     |
| -------------- | --------------------- | --------------------------------- |
| US (default)   | `api.mixpanel.com`    | Default - no configuration needed |
| EU             | `api-eu.mixpanel.com` | Must configure in SDK             |
| India          | `api-in.mixpanel.com` | Must configure in SDK             |

<Warning>
  Projects with India Data Residency **must** configure SDKs with the `api-in.mixpanel.com` host or events will be rejected.
</Warning>

## Utility Libraries

<Card title="mixpanel-utils" icon="tools" href="https://github.com/mixpanel/mixpanel-utils">
  Python utilities for data import, export, and transformation
</Card>

## Next Steps

<CardGroup cols={2}>
  <Card title="View All SDK Docs" icon="book" href="/docs/tracking-methods/sdks">
    Detailed documentation for each SDK
  </Card>

  <Card title="Best Practices" icon="lightbulb" href="/data-ingestion/best-practices">
    Learn how to implement tracking correctly
  </Card>
</CardGroup>
