tobyberesford/php-klaviyo

v0.1 2019-04-26 12:57 UTC

This package is auto-updated.

Last update: 2024-06-04 20:06:31 UTC


README

This is a fork of the official Klaviyo PHP API that also adds in GET and PUT functionality from robwittman/php-klaviyo. The Guzzle requirement of robwittman was removed by borrowing from the Order Desk PHP Client. It provides a minimal-abstraction wrapper for the track, identify, metrics, profiles, lists (v1 and v2), campaigns, and templates APIs all from the same class.

Table of Contents

  1. Metrics
  2. Profiles
  3. Lists
  4. Lists v2
  5. Campaigns
  6. Templates
  7. Track
  8. Identify

Metrics

Listing metrics

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "page"  => 1,
    "count" => 100
);
$result = $klaviyo->get("metrics", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Listing the complete event timeline

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "since" => 1400656845,
    "count" => 100,
    "sort"  => "asc"
);
$result = $klaviyo->get("metrics/timeline", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Listing the event timeline for a particular metric

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "since" => 1400656845,
    "count" => 100,
    "sort"  => "asc"
);
$result = $klaviyo->get("metric/{{METRIC_ID}}/timeline", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Exporting metric data

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "start_date"  => 2015-01-01,
    "end_date"    => 2015-01-31,
    "unit"        => "week",
    "measurement" => '["sum","ItemCount"]',
    "where"       => '[["ItemCount","=",5]]',
//  "by"          => urlencode('Accepts Marketing'),
    "count" => 100
);
$result = $klaviyo->get("metric/{{METRIC_ID}}/export", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Profiles

Retrieving a Person's Attributes

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->get("person/{{PERSON_ID}}");
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Adding or Updating a Person's Attributes

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
   '$id'                => 'dqQnNW',
   '$email'             => 'george.washington@example.com',
   '$first_name'        => 'George',
   '$last_name'         => 'Washington',
   '$phone_number'      => '555-555-5555',
   '$title'             => 'Ex-president',
   '$organization'      => 'U.S. Government',
   '$city'              => 'Mount Vernon',
   '$region'            => 'Virginia',
   '$country'           => 'US',
   '$zip'               => '22121',
   '$image'             => 'http://media.clarkart.edu/Web_medium_images/1955.16.jpg',
   '$timezone'          => 'US/Eastern',
   'favorite_ice_cream' => 'vanilla'
);
$result = $klaviyo->put("person/{{PERSON_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Listing a person's complete event timeline

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "since" => 1400656845,
    "count" => 100,
    "sort"  => "asc"
);
$result = $klaviyo->get("person/{{PERSON_ID}}/metrics/timeline", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Listing a person's event timeline for a particular metric

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "since" => 1400656845,
    "count" => 100,
    "sort"  => "asc"
);
$result = $klaviyo->get("person/{{PERSON_ID}}/metric/{{METRIC_ID}}/timeline", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Getting All People

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$result = $klaviyo->get("people");
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Lists

Lists in Account

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "type"  => "segment",
    "page"  => "1",
    "count" => "100"
);
$result = $klaviyo->get("lists", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Creating a List

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "name"        => "My New List",
    "list_type"   => "standard"
);
$result = $klaviyo->post("lists", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

List Information

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->get("list/{{LIST_ID}}");
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Updating a List

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "name" => "My New List Name"
);
$result = $klaviyo->put("list/{{LIST_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Deleting a List

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->delete("list/{{LIST_ID}}");
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Checking if Someone is in a List

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "email" => '["george.washington@example.com","thomas.jefferson@example.com"]'
);
$result = $klaviyo->get("list/{{LIST_ID}}/members", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Checking if Someone is in a Segment

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "email" => '["george.washington@example.com","thomas.jefferson@example.com"]'
);
$result = $klaviyo->get("segment/{{SEGMENT_ID}}/members", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Adding Someone to a List

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "email"          => "george.washington@example.com",
    "properties"     => '{ "$first_name" : "George", "Birthday" : "02/22/1732" }',
    "confirm_optin"  => true
);
$result = $klaviyo->post("list/{{LIST_ID}}/members", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Batch Adding People to a List

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "batch"          => '[ { "email" : "george.washington@example.com", "properties" : { "$first_name" : "George", "Birthday" : "02/22/1732" } }, { "email" : "thomas.jefferson@example.com" } ]',
    "confirm_optin"  => true
);
$result = $klaviyo->post("list/{{LIST_ID}}/members/batch", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Batch Removing People from a List

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "batch" => '[ { "email" : "george.washington@example.com" }, { "email" : "ben.franklin@example.com" } ]'
);
$result = $klaviyo->delete("list/{{LIST_ID}}/members/batch", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Exclude or Unsubscribe Someone from a List

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "email"       => "george.washington@example.com",
    "timestamp"   => 1400656845
);
$result = $klaviyo->post("list/{{LIST_ID}}/members/exclude", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

List Exclusions or Unsubscribes for a List

DEPRECATED: Please use the Lists API V2.

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "reason"   => "unsubscribe",
    "sort"     => "desc"
);
$result = $klaviyo->get("list/{{LIST_ID}}/exclusions", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

List Exclusions or Unsubscribes

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "reason"   => "unsubscribe",
    "sort"     => "desc"
);
$result = $klaviyo->get("people/exclusions", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Exclude or Unsubscribe Someone from All Email

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "email"       => "george.washington@example.com",
    "timestamp"   => 1400656845
);
$result = $klaviyo->post("people/exclusions", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Lists v2

Create a List

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "list_name" => "my new list name",
    "version"   => 2
);
$result = $klaviyo->post("lists", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Get Lists

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "version"   => 2
);
$result = $klaviyo->get("lists", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Get List Details

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "version"   => 2
);
$result = $klaviyo->get("list/{{LIST_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Update a List

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "list_name" => "my new list name",
    "version"   => 2
);
$result = $klaviyo->put("list/{{LIST_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Delete a List

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "version"   => 2
);
$result = $klaviyo->delete("list/{{LIST_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Subscribe to List

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "profiles" => '[ { "email": "george.washington@example.com", "example_property": "valueA" }, { "email": "thomas.jefferson@example.com", "example_property": "valueB" } ]',
    "version"   => 2
);
$result = $klaviyo->post("list/{{LIST_ID}}/subscribe", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Check List Subscriptions

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "emails" => '["george.washington@example.com", "john.adams@example.com"]',
    "version"   => 2
);
$result = $klaviyo->get("list/{{LIST_ID}}/subscribe", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Unsubscribe from List

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "emails" => '["george.washington@example.com", "john.adams@example.com"]',
    "version"   => 2
);
$result = $klaviyo->delete("list/{{LIST_ID}}/subscribe", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Add to List

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "profiles" => '[ { "email": "george.washington@example.com", "example_property": "valueA" }, { "email": "thomas.jefferson@example.com", "example_property": "valueB" } ]',
    "version"   => 2
);
$result = $klaviyo->post("list/{{LIST_ID}}/members", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Check List Membership

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "emails" => '["george.washington@example.com", "john.adams@example.com"]',
    "version"   => 2
);
$result = $klaviyo->get("list/{{LIST_ID}}/members", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Remove from List

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "emails" => '["george.washington@example.com", "john.adams@example.com"]',
    "version"   => 2
);
$result = $klaviyo->delete("list/{{LIST_ID}}/members", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Get All Exclusions on a List

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$args = array(
    "marker" => 123456,
    "version"   => 2
);
$result = $klaviyo->get("list/{{LIST_ID}}/exclusions/all", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Get Group Member Emails

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key, null);
$result = array(
    "marker" => 1
);

while (array_key_exists("marker", $result)) {
    $args = array(
        "marker" => $result["marker"],
        "version"   => 2
    );
    $result = $klaviyo->get("list/{{LIST_ID or SEGMENT_ID}}/members/all", $args);
    echo "<pre>" . print_r($result, 1) . "</pre>";
}
?>

Campaigns

Campaigns in Account

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "page"  => 1,
    "count" => 100
);
$result = $klaviyo->get("campaigns", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Creating a Campaign

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "list_id"              => "erRoOX",
    "template_id"          => "gtTqQZ",
    "from_email"           => "george.washington@example.com",
    "from_name"            => "George Washington",
    "subject"              => "Company Monthly Newsletter",
    "name"                 => "Campaign Name",
    "use_smart_sending"    => true,
    "add_google_analytics" => true
);
$result = $klaviyo->post("campaigns", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Campaign Information

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->get("campaign/{{CAMPAIGN_ID}}");
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Updating a Campaign

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "list_id"              => "erRoOX",
    "template_id"          => "gtTqQZ",
    "from_email"           => "george.washington@example.com",
    "from_name"            => "George Washington",
    "subject"              => "Company Monthly Newsletter",
    "name"                 => "Campaign Name",
    "use_smart_sending"    => true,
    "add_google_analytics" => true
);
$result = $klaviyo->put("campaign/{{CAMPAIGN_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Send a Campaign Immediately

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->post("campaign/{{CAMPAIGN_ID}}/send");
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Schedule a Campaign

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "send_time"   => "2013-06-14 00:00:00"
);
$result = $klaviyo->post("campaign/{{CAMPAIGN_ID}}/schedule", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Cancel a Campaign

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->post("campaign/{{CAMPAIGN_ID}}/cancel", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Clone a Campaign

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "name"     => "Cloned Campaign",
    "list_id"  => "erRoOX"
);
$result = $klaviyo->post("campaign/{{CAMPAIGN_ID}}/clone", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Campaign Recipient Information

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "count"    => 25000,
    "sort"     => "desc",
    "offset"   => "Z2VvcmdlLndhc2hpbmd0b25AZXhhbXBsZS5jb20=",
);
$result = $klaviyo->get("campaign/{{CAMPAIGN_ID}}/recipients", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Templates

List all templates

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->get("email-templates", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Creating a template

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "name" => "My New Template",
    "html" => "<html><body><p>This is an email for {{ email }}.</p></body></html>"
);
$result = $klaviyo->post("email-templates", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Updating an email template

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "name" => "My New Template",
    "html" => "<html><body><p>This is an email for {{ email }}.</p></body></html>"
);
$result = $klaviyo->put("email-template/{{TEMPLATE_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Deleting template

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$result = $klaviyo->delete("email-template/{{TEMPLATE_ID}}", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Clone template

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "name" => "My Cloned Template"
);
$result = $klaviyo->post("email-template/{{TEMPLATE_ID}}/clone", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Render template

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "context" => '{ "name" : "George Washington", "notifcation_count" : 10 }',
);
$result = $klaviyo->post("email-template/{{TEMPLATE_ID}}/render", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Render template and send email

<?php
include "Klaviyo.php";
$api_key = "pk_123456789abcdef123456789abcdef12";
$klaviyo = new Klaviyo($api_key);
$args = array(
    "from_email" => "george.washington@example.com",
    "from_name"  => "George Washington",
    "subject"    => "Company Monthly Newsletter",
    "context"    => '{ "name" : "George Washington", "notifcation_count" : 10 }'
);
$result = $klaviyo->post("email-template/{{TEMPLATE_ID}}/send", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Track

Basic Event Call

<?php
include "Klaviyo.php";
$token = "ABC123";
$klaviyo = new Klaviyo(null, $token);
$event = "Elected President";
$customer_properties = array(
    '$email' => "thomas.jefferson@example.com"
);
$properties = array(
    "PreviouslyVicePresident" => true,
    "YearElected"             => 1801,
    "VicePresidents"          => ["Aaron Burr", "George Clinton"]
);
$time = 1537057291;
$result = $klaviyo->tracker($event, $customer_properties, $properties, $time);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

However, since a GET request is being performed in the class, the following implementation is also supported:

<?php
include "Klaviyo.php";
$token = "ABC123";
$klaviyo = new Klaviyo(null, $token);
$args = array(
    "event" => "Elected President",
    "customer_properties" => array(
        '$email' => "thomas.jefferson@example.com"
    ),
    "properties" => array(
        "PreviouslyVicePresident" => true,
        "YearElected"             => 1801,
        "VicePresidents"          => ["Aaron Burr", "George Clinton"],
        '$event_id'               => 10001234,
        '$value'                  => 11.25
    ),
    "time" => 1537057291
);
$result = $klaviyo->get("track", $args);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

Identify

Basic Identify Call

<?php
include "Klaviyo.php";
$token = "ABC123";
$klaviyo = new Klaviyo(null, $token);
$properties = array(
    '$id'           => 'dqQnNW',
    '$email'        => 'george.washington@example.com',
    '$first_name'   => 'George',
    '$last_name'    => 'Washington',
    '$phone_number' => '555-555-5555',
    '$title'        => 'Ex-president',
    '$organization' => 'U.S. Government',
    '$city'         => 'Mount Vernon',
    '$region'       => 'Virginia',
    '$country'      => 'US',
    '$zip'          => '22121',
    '$image'        => 'http://media.clarkart.edu/Web_medium_images/1955.16.jpg',
    "Plan"          => "Premium",
    "SignUpDate"    => "2016-05-01 10:10:00"
);
$result = $klaviyo->identify($properties);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>

However, since a GET request is being performed in the class, the following implementation is also supported:

<?php
include "Klaviyo.php";
$token = "ABC123";
$klaviyo = new Klaviyo(null, $token);
$properties = array(
    '$id'           => 'dqQnNW',
    '$email'        => 'george.washington@example.com',
    '$first_name'   => 'George',
    '$last_name'    => 'Washington',
    '$phone_number' => '555-555-5555',
    '$title'        => 'Ex-president',
    '$organization' => 'U.S. Government',
    '$city'         => 'Mount Vernon',
    '$region'       => 'Virginia',
    '$country'      => 'US',
    '$zip'          => '22121',
    '$image'        => 'http://media.clarkart.edu/Web_medium_images/1955.16.jpg',
    "Plan"          => "Premium",
    "SignUpDate"    => "2016-05-01 10:10:00"
);
$result = $klaviyo->get("identify", $properties);
echo "<pre>" . print_r($result, 1) . "</pre>";
?>