/bento-php-sdk

🍱 Bento PHP SDK and tracking library

Primary LanguagePHP

Bento SDK for PHP Build Status

🍱 Simple, powerful analytics for PHP projects!

Track events, update data, record LTV and more in PHP. Data is stored in your Bento account so you can easily research and investigate what's going on.

👋 To get personalized support, please tweet @bento or email jesse@bentonow.com!

🐶 Find a bug? Join us on Discord and let us know!

🔥 Thank you, @arvesolland for the initial commit to this library.

Installation

This library can be installed via Composer:

composer require bentonow/bento-php-sdk 

Usage

Before tracking user or event data, create a new client. If you configured your site uuid via environment variables (BENTO_SITE_UUID) there's nothing to add. Otherwise, see the example above.

// Via .env variables
$bento = new bentonow\Bento\Bento();

or directly inject the site uuid

$bento = new bentonow\Bento\Bento('YOURSITEUUIDHERE');

Tracking Users

Identify your user

// if you have their email address, identify the user.
// do this before anything else.
$bento->identify('user@example.org');

Tag a visitor

$bento->tag('tag_1,tag_2');

Log a custom event

$bento->track('some_event',['some_key'=>'Some Value']);

Update custom fields

// you can add custom fields to your visitors which you can leverage for personalization.
$bento->updateFields(['first_name'=>'ash','last_name'=>'ketchum']);

Full Example

$bento = new bentonow\Bento\Bento();
$bento->identify('user@example.org');
$bento->updateFields(['first_name'=>'ash','last_name'=>'ketchum']);
$bento->track('$signUp',['plan'=>'Free Trial']);

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/bentonow/bento-php-sdk. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.