PHPackages                             wp-media/wp-mixpanel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. wp-media/wp-mixpanel

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

wp-media/wp-mixpanel
====================

WordPress Mixpanel Integration

v1.4.0(6mo ago)0194.3k↓13.4%[3 issues](https://github.com/wp-media/wp-mixpanel/issues)[1 PRs](https://github.com/wp-media/wp-mixpanel/pulls)1GPL-3.0-or-laterPHPPHP &gt;=7.3

Since Jun 20Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/wp-media/wp-mixpanel)[ Packagist](https://packagist.org/packages/wp-media/wp-mixpanel)[ RSS](/packages/wp-media-wp-mixpanel/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelog (7)Dependencies (9)Versions (10)Used By (1)

WP Mixpanel
===========

[](#wp-mixpanel)

A library for integrating Mixpanel analytics into WordPress projects of Group.One.

Overview
--------

[](#overview)

WP Mixpanel provides seamless integration between WordPress and Mixpanel, allowing you to track events in your WordPress projects.

Installation
------------

[](#installation)

### Via Composer

[](#via-composer)

Add the package to your project using Composer:

```
composer require wp-media/wp-mixpanel
```

Configuration
-------------

[](#configuration)

The library is composed of 3 main classes:

- `Optin` handles the status of the opt-in for analytics
- `Tracking` is the base class for interaction with Mixpanel
- `TrackingPlugin` extends the `Tracking` class with some specific configuration for usage in WordPress plugins

### Initialize the `Tracking` class alone

[](#initialize-the-tracking-class-alone)

```
new WPMedia\Mixpanel\Tracking( $mixpanel_token, $options = [] );
```

The `$mixpanel_token` is the token provided by Mixpanel corresponding to the project you want to send data to.

For Group.One, we have a sandbox project and a production project.

The `$options` parameter is an optional array which can be used to configure further the Mixpanel PHP library configuration.

### Initialize the `TrackingPlugin` in a WordPress plugin

[](#initialize-the-trackingplugin-in-a-wordpress-plugin)

```
new WPMedia\Mixpanel\TrackingPlugin( $mixpanel_token, $plugin, $brand = '', $app = '' );
```

- The `$plugin` is the plugin name + the version
- The `$brand` and `$app` are optional, but should be specified based on the analytics requirements of the plugin you implement the library in.

### Initialize the Optin class

[](#initialize-the-optin-class)

```
new WPMedia\Mixpanel\Optin( $plugin_slug, $capability );
```

- The `$plugin_slug` is the slug used in your plugin as the prefix for options
- The `$capability` is the capability required to be able to modify the value of the optin

Usage Examples
--------------

[](#usage-examples)

### Track a simple event without optin

[](#track-a-simple-event-without-optin)

```
$tracking->identify( $user_id );
$tracking->track( 'Event Name', $properties );
```

Calling `identify()` is required to associate sent events with a user ID. The `$user_id` provided is automatically hashed with the appropriate algorithm.

The `track()` method takes 2 required arguments:

- The `$event_name` corresponding to the event name which should be displayed in Mixpanel. Events use Start Case formatting.
- The `$properties` is an array of properties to associate with the event in the format `property_name => value`. Properties use small caps formatting and underscores.

### Track an event with optin check in a plugin

[](#track-an-event-with-optin-check-in-a-plugin)

```
if ( ! $optin->can_track() ) {
    return;
}

$tracking_plugin->identify( $user_id );
$tracking_plugin->track( 'Event Name', $properties, $event_capability = '' );
```

The `track()` method of the `TrackingPlugin` class is a bit different than its parent:

First, it takes an additional optional parameter `$event_capability`. By default, the capability required for all events is `manage_options`. This can be changed in two different ways:

- Using the filter `wp_mixpanel_event_capability` to modify the value for all events
- Passing the capability as the parameter `$event_capability`, to set it on a specific event

Second, the method will automatically associate the following properties to the event:

- `domain`: hashed value of the current hostname
- `wp_version`: current WP version
- `php_version`: current PHP version
- `plugin`: Plugin name and version (set in constructor)
- `brand`: Brand name (set in constructor)
- `application`: Application name (set in constructor)

### `wp_mixpanel_event_capability` Filter usage

[](#wp_mixpanel_event_capability-filter-usage)

The filter can takes 3 arguments:

- `$capability` the capability for all events
- `$event` the current event name
- `$app` the current app name

Read more about MixPanel at group.one
=====================================

[](#read-more-about-mixpanel-at-groupone)

More information about how MixPanel is used at group.one is available in [our internal documentation](https://group-one.atlassian.net/wiki/spaces/PA1/folder/33940931155?atlOrigin=eyJpIjoiZGNhYmI5MDMyZmZiNGY4MmIzOWZkNDNmZmY3ZjcyNDAiLCJwIjoiYyJ9).

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance68

Regular maintenance activity

Popularity34

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 88.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~21 days

Total

7

Last Release

188d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5564218f7cd2ccf4542a09b7c5436e61e6b370c97fb3b04db1c5bbc0cc67e3c1?d=identicon)[wpmedia](/maintainers/wpmedia)

---

Top Contributors

[![remyperona](https://avatars.githubusercontent.com/u/3465180?v=4)](https://github.com/remyperona "remyperona (23 commits)")[![Miraeld](https://avatars.githubusercontent.com/u/14993267?v=4)](https://github.com/Miraeld "Miraeld (2 commits)")[![MathieuLamiot](https://avatars.githubusercontent.com/u/15233030?v=4)](https://github.com/MathieuLamiot "MathieuLamiot (1 commits)")

### Embed Badge

![Health badge](/badges/wp-media-wp-mixpanel/health.svg)

```
[![Health](https://phpackages.com/badges/wp-media-wp-mixpanel/health.svg)](https://phpackages.com/packages/wp-media-wp-mixpanel)
```

###  Alternatives

[sensiolabs/minify-bundle

Assets Minifier (CSS, JS) for Symfony &amp; Minify integration in Asset Mapper

5694.9k1](/packages/sensiolabs-minify-bundle)[sider/phinder

PHP code piece finder

5445.5k](/packages/sider-phinder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
