Note: This documentation is for Opentracker's events engine, please contact us if you think you need an upgrade.
Note: Before you can start using app analytics, you first need to register your app here

Opentracker's events engine supports tracking of iOS users and native app events.

This is done by including the Opentracker iOS library in your app and following the instructions below.

The Opentracker iOS library includes functions and listeners so you can easily insert your custom events into Opentracker.net's events engine.

7 easy steps to start tracking your app

Add iOS libraries 1 Signup or add your app to an existing account (receive signup email).
Add iOS libraries 2 Download the iOS client zip file and unzip. You should now have a folder called Opentracker-iOS-xxx
Add Opentracker iOS libraries 3 Open your project in Xcode, and drag the OTLibrary folder (located in the Opentracker-iOS directory) into your application's project directory in order to include the tracking library. Copy items into destination Group's folder and select 'Create groups for any added folders'.

You should now have a new directory in your project called 'OTLibrary' with the Opentracker classes inside.
Add iOS libraries 4 Add the following import statement to your application's delegate file below (eg <YourApplication>AppDelegate.m):
#import "OTLogService.h"
Opentracker github 5 Next, we have to initialize the OTLogService object in the Application delegate. (<YourApplication>AppDelegate.m) This opens the session and logs the session data on start of the application. (example)
This is done in the function: applicationDidFinishLaunching or didFinishLaunchingWithOptions of the application. APP_NAME is the name of the application registered in opentracker.
Note: This is an example. your AppDelegate.m will probably look different.
- (BOOL)application:(UIApplication *)application 
  didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    [[OTLogService sharedOTLogService] onLaunch:@"APP_NAME"];
    [[OTLogService sharedOTLogService] sendEvent:@"start session" ];

}

Add the following code to the end of applicationDidEnterBackground. This pauses the session when the app goes into the background and attempts an upload. (example)

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [[OTLogService sharedOTLogService] onEnteringBackground ];
}
Add the following code to the end of applicationWillEnterForeground. This tags an event to resume the previous session or create a new one if more than 30 minutes have passed and upload any data (nothing happens if data was successfully uploaded by the applicationDidEnterBackground call). (example)
 - (void)applicationWillEnterForeground:(UIApplication *)application {
  [[OTLogService sharedOTLogService] sendEvent:@"resume session" ];
}
Call the following function in the applicationWillTerminate function. Under normal circumstances this function will not be called but there are some cases where the OS will terminate the app. (example)
   - (void)applicationWillTerminate:(UIApplication *)application
{
    //close opentracker session
    [[OTLogService sharedOTLogService] onTerminate];
}
Add iOS libraries 6 Add your events (as many as you like, anywhere you see fit, just like logging).
[[OTLogService sharedOTLogService] sendEvent:@"My Event" ];
Note: Dont forget to add the import function from step 4 to all the xxx.Contoller.m files you want to log events in
Also: In order to avoid collecting too much data, do not call this function in a loop.
Add iOS libraries 7 Finally, we need to add the following 4 Libraries if they are not already included in your project:

  • Libz.dylib
  • SystemConfiguration.framework
  • CoreLocation.framework
  • CoreTelephony.framework
To add these, click on your project in the Project Navigator. You will see the project view. Select your target and click on the 'Build Phases' tab. Link Binaries with Libraries; expander and click the '+' button. Search for the above 4 libraries in the list displayed and add them one by one. See screenshot below.

Power features

To use OTLogService to its full potential, you can add property name/ value pairs to an event.
For example if you have an event going to an advertisement use the following

We recommend adding a title value pair. If there is no title defined, the title will default to '[no title]'

// Example of sending a multi-dimensional event
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init ];
  [dictionary setObject:@"HP ad tapped" forKey:@"title"];
  [dictionary setObject:@"http://www.hp.com/external/link.html" forKey:@"ad link"];
  [dictionary setObject:@"$20" forKey:@"value"];
  [dictionary setObject:@"Overview screen" forKey:@"source"];
  [[OTLogService sharedOTLogService]  sendEvent:dictionary ];

Counting

Opentracker's events engine includes counting functionality with segmentation within the API calls.

Info Please see inserting events with a url for more details on the mechanics

An example

The following example will add a shopping cart event:

// Example of sending a custom event called apple and increase the count by 10
NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init ];
  [dictionary setObject:@"title" forKey:@"My Title"];
  [dictionary setObject:@"Panasonic Lumix DMC-TZ30" forKey:@"item"];
  [dictionary setObject:@"Panasonic" forKey:@"brand!"];
  [dictionary setObject:@"257" forKey:@"price"];
  [dictionary setObject:@"camera[+257]" forKey:@"itemtype"];
  [[OTLogService sharedOTLogService]  sendEvent:dictionary ];

Enable geo-location

To enable location services, you need to add the parameter [OTLogService setLocationServices:YES]to your AppDelegate file. It is disabled by default.

Example

A full example of an iOS xCode project with Opentracker code can be found here

Overriding default properties

In certain cases you might want to override some values for certain properties. See below for instructions on how to do so.

App & browsers

This property can only be overridden in Android and iOS.

You can override the default browser or App name by submitting the 'browser' variable. You can also specify a version.

example

    [dictionary setObject:@"My cool app" forKey:@"browser"];
    [dictionary setObject:@"1.5.2" forKey:@"browserVersion"];

Visible in:

  • Apps & Browsers
  • All browser segments

 

We would love to hear your feedback. Please use the facebook comment box below