### Install laravel-mixpanel-api via Composer Source: https://github.com/jeffersongoncalves/laravel-mixpanel-api/blob/main/README.md Install the package via Composer. ```bash composer require jeffersongoncalves/laravel-mixpanel-api ``` -------------------------------- ### Get a funnel with MixpanelApi::getFunnel Source: https://github.com/jeffersongoncalves/laravel-mixpanel-api/blob/main/README.md Get funnel data using the MixpanelApi facade. ```php $funnel = MixpanelApi::getFunnel('42', '2026-08-01', '2026-08-31'); ``` -------------------------------- ### Get retention data with MixpanelApi::getRetention Source: https://github.com/jeffersongoncalves/laravel-mixpanel-api/blob/main/README.md Get retention data using the MixpanelApi facade. ```php $retention = MixpanelApi::getRetention('2026-08-01', '2026-08-31', 'signup'); ``` -------------------------------- ### Publish mixpanel-api-config Source: https://github.com/jeffersongoncalves/laravel-mixpanel-api/blob/main/README.md Publish the package configuration file. ```bash php artisan vendor:publish --tag=mixpanel-api-config ``` -------------------------------- ### Run tests with composer test Source: https://github.com/jeffersongoncalves/laravel-mixpanel-api/blob/main/README.md Run the package test suite. ```bash composer test ``` -------------------------------- ### Default config/mixpanel-api.php Source: https://github.com/jeffersongoncalves/laravel-mixpanel-api/blob/main/README.md Default configuration file for the package, reading credentials from environment variables. ```php // config/mixpanel-api.php return [ 'token' => env('MIXPANEL_TOKEN', ''), 'api_key' => env('MIXPANEL_API_KEY', ''), 'secret' => env('MIXPANEL_SECRET', ''), 'project_id' => env('MIXPANEL_PROJECT_ID', ''), ]; ``` -------------------------------- ### Track an event with MixpanelApi::trackEvent Source: https://github.com/jeffersongoncalves/laravel-mixpanel-api/blob/main/README.md Track an event using the MixpanelApi facade. Requires the project token. ```php use JeffersonGoncalves\MixpanelApi\Facades\MixpanelApi; MixpanelApi::trackEvent('signup', $user->id, [ 'plan' => 'pro', ]); ``` -------------------------------- ### Update a user profile with MixpanelApi::setProfile Source: https://github.com/jeffersongoncalves/laravel-mixpanel-api/blob/main/README.md Update a user profile using the MixpanelApi facade. Requires the project token. ```php MixpanelApi::setProfile($user->id, [ '$email' => $user->email, '$name' => $user->name, ]); ``` -------------------------------- ### Configure Mixpanel credentials in .env Source: https://github.com/jeffersongoncalves/laravel-mixpanel-api/blob/main/README.md Set Mixpanel credentials in the .env file. The token is used for ingestion, while the API key, secret, and project ID are used for query/export endpoints. ```env MIXPANEL_TOKEN=your-project-token MIXPANEL_API_KEY=your-api-key MIXPANEL_SECRET=your-api-secret MIXPANEL_PROJECT_ID=your-project-id ``` -------------------------------- ### Query events with MixpanelApi::queryEvents Source: https://github.com/jeffersongoncalves/laravel-mixpanel-api/blob/main/README.md Query events (Insights) using the MixpanelApi facade. fromDate/toDate default to the last 30 days when omitted. ```php $insights = MixpanelApi::queryEvents('purchase', '2026-08-01', '2026-08-31'); ``` -------------------------------- ### Export raw events with MixpanelApi::exportEvents Source: https://github.com/jeffersongoncalves/laravel-mixpanel-api/blob/main/README.md Export raw events as newline-delimited JSON. The response is returned as a raw string; parse each line separately. ```php $ndjson = MixpanelApi::exportEvents('2026-08-01', '2026-08-31', 'signup'); foreach (explode(PHP_EOL, trim($ndjson)) as $line) { $event = json_decode($line, true); } ``` -------------------------------- ### Handle InvalidArgumentException from MixpanelApi Source: https://github.com/jeffersongoncalves/laravel-mixpanel-api/blob/main/README.md Handle InvalidArgumentException thrown when required credentials are missing. ```php try { MixpanelApi::trackEvent('signup', $user->id); } catch (InvalidArgumentException $e) { logger()->error($e->getMessage()); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.