ConvertLoop PHP API Client
A PHP client of the ConvertLoop REST API. You can sign up for a ConvertLoop account at http://convertloop.co., (*1)
Installation
Requirements
PHP 5.3.3 and later., (*2)
Composer
To install this library using Composer run the following command:, (*3)
composer require convertloop/convertloop-php
To use it, use Composer's autoload:, (*4)
require_once('vendor/autoload.php');
Getting Started
First, you need to create an instance of ConvertLoop\ConvertLoop
class passing your app_id
and api_key
:, (*5)
$convertloop = new \ConvertLoop\ConvertLoop("app_id", "api_key", "v1");
You are now ready to start calling the API methods:, (*6)
Creating or updating a person
You need to pass at least one of the following: pid
, user_id
or email
to identify a user. Use pid
when you are updating a guest of your site (you can obtain this value from the cookie dp_pid
). Use user_id
to match the id
of the user in your application., (*7)
$person = array(
"email" => "german.escobar@convertloop.co",
"first_name" => "German",
"last_name" => "Escobar",
"plan" => "free"
);
$convertloop->people()->createOrUpdate($person);
Any key different to pid
, user_id
, email
, first_seen_at
, last_seen_at
, add_to_segments
, and remove_from_segments
will be treated as a custom attribute of the person., (*8)
You can add or remove people from a segment ussing the add_to_segments
and remove_from_segments
keys:, (*9)
$person = array(
"email" => "german.escobar@convertloop.co",
"add_to_segments" => array("Learn Something"),
"remove_from_segments" => array("Segment 1")
);
$convertloop->people()->createOrUpdate($person);
Tracking an event
You can track an event for any person:, (*10)
$person = array("email" => "german.escobar@convertloop.co");
$event = array(
"name" => "Billed",
"person" => $person,
"metadata" => array("credits" => 1000),
"ocurred_at" => time()
);
$convertloop->eventLogs()->send($event);
If you don't specify the ocurred_at
key, the current time will be used. You can use the person
key to add custom attributes to that person, or add or remove that person to/from segments., (*11)