2017 © Pedro Peláez
 

cakephp-plugin cakephp-mixpanel

CakePHP plugin providing easy integration with Mixpanel's analytics

image

okatsuralau/cakephp-mixpanel

CakePHP plugin providing easy integration with Mixpanel's analytics

  • Tuesday, May 16, 2017
  • by okatsuralau
  • Repository
  • 1 Watchers
  • 0 Stars
  • 18 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Software License Build Status Build Status Latest Stable Version , (*1)

CakePHP Mixpanel Plugin

This plugin provides a Mixpanel component to track events from your controllers using the official Mixpanel PHP library., (*2)

Requirements

  • PHP >= 5.6
  • CakePHP >= 3.0

How to Install

composer require okatsuralau/cakephp-mixpanel@1.0.0

How to Use

Load the plugin in your config/bootstrap.php file:, (*3)

Plugin::load('CakephpMixpanel');

Add the plugin configurations in your config/app.php or config/app_custom.php file:, (*4)

return [
    //...

    'Mixpanel' => [
        'token' => YOUR_TOKEN_HERE
    ]
]

Load the component in your src/Controller/AppController.php, (*5)

public function initialize()
{
    parent::initialize();

    $this->loadComponent('CakephpMixpanel.Mixpanel');
}

and (optionally) add the following code to your beforeFilter() method to identify the users actions, (*6)

public function beforeFilter(\Cake\Event\Event $event)
{
    // if a user is logged in
    $this->Mixpanel->identify($user_id);
    $this->Mixpanel->name_tag($user_name);
    $this->Mixpanel->register($superProperties);

    /* To make use of the people API */
    $this->Mixpanel->people($this->Auth->user('id'), array(
        '$username' => $this->Auth->user('username'),
        '$email' => $this->Auth->user('email'),
        '$created' => $this->Auth->user('created'),
        '$last_login' => $this->Auth->user('connected'),
        'my_custom_var' => $my_custom_var,
    ));

    // ...

    parent::beforeFilter($event);
}

To register an event, put the following code in your controller action. src/Controller/PostController.php, (*7)

public function index()
{
    // ...

    $this->Mixpanel->track(
        'Post list', 
        [
            'author' => $this->Auth->user('name'),
            'category' => 'Post',
        ]
    );
}

public function create()
{
    if ($this->request->is('post')) {

        // ...

        $this->Mixpanel->track(
            'Post Created', 
            [
                'author' => $this->Auth->user('name'),
                'category' => 'Post',
            ]
        );

        $this->redirect(array('action'=>'index'));
    }
}

This should be enough to start sending events to Mixpanel., (*8)

License

Copyright 2017 Gabriel Lau, (*9)

Available for you to use under the MIT license. See: http://www.opensource.org/licenses/MIT, (*10)

The Versions

16/05 2017

dev-master

9999999-dev https://github.com/okatsuralau/CakePHP-Mixpanel

CakePHP plugin providing easy integration with Mixpanel's analytics

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gabriel Lau

cakephp mixpanel

10/05 2017

v1.0.4

1.0.4.0 https://github.com/okatsuralau/CakePHP-Mixpanel

CakePHP plugin providing easy integration with Mixpanel's analytics

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gabriel Lau

cakephp mixpanel

10/05 2017

v1.0.3

1.0.3.0 https://github.com/okatsuralau/CakePHP-Mixpanel

CakePHP plugin providing easy integration with Mixpanel's analytics

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gabriel Lau

cakephp mixpanel

10/05 2017

v1.0.2

1.0.2.0 https://github.com/okatsuralau/CakePHP-Mixpanel

CakePHP plugin providing easy integration with Mixpanel's analytics

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gabriel Lau

cakephp mixpanel

09/05 2017

v1.0.1

1.0.1.0 https://github.com/okatsuralau/CakePHP-Mixpanel

CakePHP plugin providing easy integration with Mixpanel's analytics

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gabriel Lau

cakephp mixpanel

06/05 2017

v1.0.0

1.0.0.0 https://github.com/okatsuralau/CakePHP-Mixpanel

CakePHP plugin providing easy integration with Mixpanel's analytics

  Sources   Download

MIT

The Requires

 

The Development Requires

by Gabriel Lau

cakephp mixpanel