The \Infinario\Infinario class provides access to the Infinario PHP tracking API. The SDK requires PHP >= 5.3.2 and php5-curl.
Install the latest version with Composer:
composer require infinario/infinarioIn order to track events, instantiate the class at least with your project token (can be found in Project Management in your Infinario account), for example:
use Infinario\Infinario; $infinario = new Infinario('12345678-90ab-cdef-1234-567890abcdef'); // PRODUCTION ENVIRONMENT // $infinario = new Infinario('12345678-90ab-cdef-1234-567890abcdef', ['debug' => true]); // DEVELOPMENT ENVIRONMENTYou can also provide a PSR-3 compliant logger interface:
$infinario = new Infinario('12345678-90ab-cdef-1234-567890abcdef', ['logger' => $logger]);Timeout for sending data is set to 1000ms you can overwrite it by following option:
$infinario = new Infinario('12345678-90ab-cdef-1234-567890abcdef', ['timeout' => 500]);When tracking events, you have to specify which customer generated them. This can be either done right when calling the client's constructor.
use Infinario\Infinario; $infinario = new Infinario('12345678-90ab-cdef-1234-567890abcdef', ['customer' => 'john123']);or by calling identify.
$infinario->identify('john123');To track events for the currently selected customer, simply call the track method.
$infinario->track('purchase');You can also specify an array of event properties to store with the event.
$infinario->track('purchase', ['product' => 'bottle', 'amount' => 5]);You can also update information that is stored with a customer.
$infinario->update(['first_name' => 'John', 'last_name' => 'Smith']);