PHP code example of mixpanel / mixpanel-php

1. Go to this page and download the library: Download mixpanel/mixpanel-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mixpanel / mixpanel-php example snippets



// import dependencies
nstance, replace with your project token
$mp = Mixpanel::getInstance("MIXPANEL_PROJECT_TOKEN");

// track an event
$mp->track("button clicked", array("label" => "sign-up")); 

// create/update a profile for user id 12345
$mp->people->set(12345, array(
    '$first_name'       => "John",
    '$last_name'        => "Doe",
    '$email'            => "[email protected]",
    '$phone'            => "5555555555",
    "Favorite Color"    => "red"
));


// import Mixpanel
ss instance, replace with your project token
$mp = Mixpanel::getInstance("MIXPANEL_PROJECT_TOKEN");

// track an event
$mp->track("button clicked", array("label" => "sign-up"));

// create/update a profile for user id 12345
$mp->people->set(12345, array(
    '$first_name'       => "John",
    '$last_name'        => "Doe",
    '$email'            => "[email protected]",
    '$phone'            => "5555555555",
    "Favorite Color"    => "red"
));
json
"...
    "mixpanel/mixpanel-php" : "2.*"
    ...
}