Upsight logo Back to top

Quick Start Guide

The Basics


This is a PHP SDK around Upsight Data Collection API. It provides methods to make the API calls for all the different message types supported by Upsight Analytics.

Download SDK

To get started with the Upsight library, you will need to check-out the kontagent_api.php file from our GitHub and include it in your project. You will also need to instantiate and configure an instance of the Kontagent object.

<?php

// include the library
require_once('./kontagent_api.php');

// configure and instantiate Upsight object
$ktApi = new KontagentApi($ktApiKey, array('useTestServer' => true, 'validateParams' => true));

?>

Using the Library

Overview


Once you've got your Upsight object integrated and configured you can start using the library. There are two types of methods provided in the library: tracking methods and helper methods.

Using the Library

Tracking Methods


The tracking methods should get called by your application whenever you need to report an event to Upsight. There is a tracking method available for every message type in the Upsight API. A few examples are:

<?php

$ktApi->trackApplicationAdded($userId);
$ktApi->trackPageRequest($userId); 
$ktApi->trackEvent($userId, $eventName, array('value' => 5));
$ktApi->trackRevenue($userId, $value, array('type' => 'credits'));

>?

When events happen within your application, you should make the appropriate call to Upsight. We will then crunch and analyze this data in our systems and present them to you in your dashboard.

For a full list of the available tracking methods, refer to the PHP SDK specification.

Using the Library

Helper Methods


The library provides a few helper methods for common tasks. Currently the only ones available are:

<?php

$ktApi->genUniqueTrackingTag();
$ktApi->genShortUniqueTrackingTag();

>?

These methods will help you generate the tracking tag parameters required to link certain messages together (for example: invite sent -> invite response -> application added).

Facebook


If you are not instrumenting with the Upsight Facebook SDK and instead instrumenting with this wrapper, you may run into some issues. Please see our Facebook Best Practices page for troubleshooting tips.

HTTPS


If sending a request to HTTPS, set optionalParams.useHttps to TRUE in the constructor, just as would set userTestServer to true when using the test server.