With the iOS Tracking Library you can track users and their actions on your iPhone or iPad application.
Clone the latest version of our Stetic iOS Tracking Library from Github to your local machine using the following command in your terminal:
git clone https://github.com/stetic/stetic-ios-library.git
Add the files from this repository to your iOS project. If you're using XCode, just drag and drop the files to your XCode Project Workspace.
Import the Stetic Header file in your Application Delegate (AppDelegate.m):
#import "Stetic.h"
Initialize the library with the startSession method in your Application Delegate inside didFinishLaunchingWithOptions:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[Stetic sharedInstance] startSession:@"YOUR_SITE_TOKEN"]; }
Replace YOUR_SITE_TOKEN
with your site token.
Start tracking events in your app. The best way is to track an event in every view inside viewDidLoad.
Hint: Use the appview
event here to use our pre-configured events.
- (void)viewDidLoad { [super viewDidLoad]; [[Stetic sharedInstance] track:@"appview" properties:@{@"view": @"MyView"}]; }
You can add more properties for better segmentation:
[[Stetic sharedInstance] track:@"appview" properties:@{@"view": @"MyView", @"property": @"value"}];
Track any event you like:
[[Stetic sharedInstance] track:@"video play" properties:@{@"title": @"My awesome video", @"author": @"Jimmy Schmidt"}];
Identify users. Call the identify method BEFORE the track method:
[[Stetic sharedInstance] identify:@"id" value: user.id]; // Key value [[Stetic sharedInstance] identify:@{@"id": user.id, @"email": user.email, @"name": user.name}]; // NSDictionary [[Stetic sharedInstance] track:@"appview" properties:@{@"view": @"MyView"}];