iOS

Releases

Setup

  • Add the KISSmetricsSDK.framework to your project.

  • Within AppDelegate.m, import the framework like so:

#import <KISSmetricsSDK/KISSmetricsAPI.h>
  • Still in the AppDelegate.m file, find the didFinishLaunching or didFinishLaunchingWithOptionsmethod and add the following code as the first line in that method. Be sure to apply your API key.

[KISSmetricsAPI sharedAPIWithKey:@"ADD API KEY HERE"];

Initializing with Development and Production keys

#ifndef DEBUG
    [KISSmetricsAPI sharedAPIWithKey:@"yourDevelopmentProductKeyHere"];
#elif RELEASE
    [KISSmetricsAPI sharedAPIWithKey:@"yourProductionProductKeyHere"];
#endif

Example Calls

// Initialize the API
[KISSmetricsAPI sharedAPIWithKey:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxx"];
// Identifying Users
[[KISSmetricsAPI sharedAPI] identify:@"name@email.com"]; // Replace @"name@email.com" with code that gets the identity of your user!
// Track Event
[[KISSmetricsAPI sharedAPI] record:@"My Event"];
[[KISSmetricsAPI sharedAPI] recordEvent:@"My Event"];    // recordEvent() is being deprecated
// Track Event with Properties
NSDictionary *myEventProperties = [[NSDictionary alloc]
  initWithObjectsAndKeys:@"Value", @"My Property", nil];
[[KISSmetricsAPI sharedAPI] record:@"My Event With Properties"
  withProperties:myEventProperties];
// Set Properties
NSDictionary *myEventProperties = [[NSDictionary alloc]
  initWithObjectsAndKeys:@"Value", @"My Property", nil];
[[KISSmetricsAPI sharedAPI] set:myEventProperties];
[[KISSmetricsAPI sharedAPI] setProperties:myEventProperties];  // setProperties() is being deprecated
/* New Functions as of v2 */
// Track an event only once per set identity. After an identity is cleared or a new identity is set, the condition will pass once again.
[[KISSmetricsAPI sharedAPI] record:@"Viewed feature" onCondition:KMARecordOncePerIdentity];
// Track an event only once per install
[[KISSmetricsAPI sharedAPI] record:@"Installed App" onCondition:KMARecordOncePerInstall];
// Set user properties only if they have changed on the device
[[KISSmetricsAPI sharedAPI] setDistinct:@"7.1" forKey:"OS version"];

Optional Automated Tracking

  1. autoRecordInstalls() Calling this records two events:

  • Installed App

  • Updated App

  1. autoSetAppProperties() Calling this sets the following properties:

  • App Version : 1.0.0

  • App Build : 101

  1. autoSetHardwareProperties() Calling this sets the following properties:

  • Device Manufacturer: Apple

  • Device Platform: iPhone

  • Device Model: iPhone 5s

  • System Name: iOS

  • System Version: 7.0.4

Performance

In the new SDK, all calls to record events, properties, identities and aliases are immediately passed onto a background thread for processing and delivery.

In our version 1, the processing of these calls was handled by the same thread that made the call to record before being delivered asynchronously. This wasn’t optimal as an application’s main thread is responsible for view updates and user interactions.

As a third party addition to our customers’ apps, we should use as little of the main thread as possible to ensure that our SDK doesn’t contribute to any lag in the users’ experience of their apps.

Send Queue Archiving

The SDK will archive all activity in a send queue and attempt to deliver from that queue as connectivity permits.

iOS v2 SDK specs

  • Size (compiled): 942kb

  • Memory Overhead

  • idle: 330.32kb (under iOS 7)

  • per avg. event with properties: estimated at < 500 bytes (< 200 for required params plus assumed < 300 bytes for average event with properties). During archiving of each event with properties, approximately 3kb of memory is allocated and quickly released.

  • iOS version support: iOS 5.1 (>99% of iOS devices)

Last updated