Skip to content

martinstrycek/php-sdk

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Infinario PHP SDK

The \Infinario\Infinario class provides access to the Infinario PHP tracking API. The SDK requires PHP >= 5.3.2 and php5-curl.

Installation

Install the latest version with Composer:

composer require infinario/infinario

Getting started

In 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 ENVIRONMENT

You 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]);

Identifying the customer

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');

Tracking events

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]);

Updating customer properties

You can also update information that is stored with a customer.

$infinario->update(['first_name' => 'John', 'last_name' => 'Smith']);

About

Infinario PHP SDK

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%