定制 wp-media/wp-mixpanel 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wp-media/wp-mixpanel

Composer 安装命令:

composer require wp-media/wp-mixpanel

包简介

WordPress Mixpanel Integration

README 文档

README

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

Overview

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

Installation

Via Composer

Add the package to your project using Composer:

composer require wp-media/wp-mixpanel

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

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

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

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

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

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

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

More information about how MixPanel is used at group.one is available in our internal documentation.

wp-media/wp-mixpanel 适用场景与选型建议

wp-media/wp-mixpanel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 289.53k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 05 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 wp-media/wp-mixpanel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 wp-media/wp-mixpanel 我们能提供哪些服务?
定制开发 / 二次开发

基于 wp-media/wp-mixpanel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 289.53k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 12
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2025-05-22