The KISSmetrics API client

0.4.0 2021-03-12 21:07 UTC

This package is not auto-updated.

Last update: 2021-05-07 21:48:12 UTC


Build Status

KISSmetrics PHP client that doesn't overuse the singleton pattern and has a slightly better API and no built-in cron support (that's a feature). Here's how to use it:

$km = new KISSmetrics\Client('API key', KISSmetrics\Transport\Sockets::initDefault()); // Initialize

$km->identify('')   // Identify user (always)
  ->alias('old-anonymous-cookie')  // Alias to previously anonymous user, maybe
  ->set(array('gender' => 'male')) // Set some property
  ->record('Viewed thing');        // Record an event, optionally with properties

$km->submit(); // Submit all that to KISSmetrics in one go

In case of errors this thing throws a KISSmetrics\ClientException so if you have a fire-and-forget attitude to these metrics just try/catch those. Though it's helpful when you want to make sure everything is setup correctly!


  "require": {
    "kissmetrics/kissmetrics-php": "~0.4.0"


Licensed under the MIT license.