Overview

Optimise iOS SDK is an advance tracking tool which helps in tracking app installation, registration and sales (in-app purchase). Please read the following steps carefully to integrate our SDK in your app.

optimise-ios-sdk-overview

1. Download the SDK

Download the iOS tracking SDK 2.3

2. Integrating SDK to your Application

a). Adding Optimise Mobile Tracking framework

Drag and drop the OptimiseMobileTracking.framework into your project and click on finish button.

ios_Track_1

b). Link Library to project

  1. Select TARGETS > select general
  2. Click on “+” embedded binaries

ios_Track_2

Select OptimiseMobileTracking.framework and click on Add button

ios_Track_3

c). Swift support

If your app is build in Swift than refer iOS mobile app tracking Swift support.

d). Add script to remove unsupported architecture

If you are getting an error regarding unsupported architecture during build than please follow the steps mentioned below

1. Select Targets, under build phases click on ‘+’ icon to add ‘New Run Script Phase’ as shown below

ios_tracking_add_script

 

2. Copy and paste the following script inside the box. Make sure show environment variables in build log and Run script only when installing should be checked.

    APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
    # This script loops through the frameworks embedded in the application and
    # removes unused architectures.
    find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
    do
    FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
    FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
    echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
    EXTRACTED_ARCHS=()
    for ARCH in $ARCHS
    do
    echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
    lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
    EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
    done
    echo "Merging extracted architectures: ${ARCHS}"
    lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
    rm "${EXTRACTED_ARCHS[@]}"
    echo "Replacing original executable with thinned version"
    rm "$FRAMEWORK_EXECUTABLE_PATH"
    mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
    done

To achieve this please refer the following example

iOS_osx_architecture_script

e). Call Optimise SDK Tracking Methods

Yon need to import SDK header file. e.g:- #import <OptimiseMobileTracking/OptimiseMobileTracking.h>.

ios_Track_4

 

f). Create SDK Instance and set Global variable

You need to call the following methods of OptimiseSDK:

// Developer can get instance of OMGSDK with OMGSDK sharedManager.  
OMGSDK*omgInstance = [OMGSDK sharedManager]; 

Global variables

Parameter Type Required? Description
Application Key String Yes The unique key provided by Optimise.
MID Integer Yes The merchant Id provided by Optimise.

Please contact your account manager from Optimise to get Application key, MID and PID values.

for example:
[sdkInstance setApplicationKey:@"applicationkey"];
[sdkInstance setMID:66666];

Track Install

Call trackInstall method inside didFinishLaunchingWithOptions. Our SDK will hit this method only once when app gets installed in users device.

example- [sdkInstance trackInstallWhereAppID:@"12345" pid:12213 deepLink:YES Ex1:@"" Ex2:@"" Ex3:@"" Ex4:@"" Ex5:@""];

Pass the Following Parameters as an NSDictionary, dictionary holds the value for key.

Parameter  Type Required? Description
AppID String Optional A unique transaction reference such as an order number. For track install please set this as blank or null.
PID Integer Yes The product id (pid) provided by optimise.
Deeplink Bool Yes This is a boolean variable. If you want to enable deeplink in your app than set this as true else you can set this as false.
EX1-EX5 String  Optional Extended Data 1. Pass any additional variable you would like to capture or pass Ex1:@”Install” in case of trackInstall in field. e.g:- @””,@”Install”.

Track Event

Call our trackEvent method For tracking sales (in-app purchase) and registration. Follow below steps to use this method:-

1. For tracking sales call this method on successful transaction of product.

2. For tracking user registration call this method just after the user is successfully registered in app. For example call this after mobile number verification or after user login in app.

example- [sdkInstance trackEventWhereAppID:@"12345" pid:22222 status:@"100.9" currency:@"INR" Ex1:@"" Ex2:@"" Ex3:@"" Ex4:@"" Ex5:@""];

The parameter to pass over here as a NSArray, array  holds the values.

Parameter Type Required? Description
AppId String Optional Pass a unique transaction reference such as an order number in case of tracking sale. In case of tracking registration you can pass empty or null in this.
PID Integer Yes The product id (pid) provided by optimise.
Status String Optional To validate a transaction pass the order value here. e.g. if order value (product price) is 100 pass 100 in it or if it is 89.9 than pass 89.9 in it.
Currency String Yes 3 digit ISO standard value currency e.g. INR, GBP
EX1-EX5 String  Optional Extended Data. Pass any additional variable you would like to capture or pass Ex1 = “Sale” in case of tracking sale. Pass Ex1 = “Registration” in case of tracking user registration.

 Sdk methods to be called

ios_track_5

Enable Location based tracking (optional)

Location based tracking enables you an option to track location based installs. To achieve this add the following steps in application

Add key’s in info.plist

  • NSLocationWhenInUseUsageDescription
  • NSLocationAlwaysUsageDescription

e.g.

example_adding_keys

Add core location framework

core_location_framework

Create instance of CLLocationManagerinstace_cll_location_manager

Initialize location manager instance

location_manager_instance

Add delegate methods and get latitude/longitude values

add_delegate_methods

Final code will looks like as:

final_code

Set latitude and longitude value to SDK

double tempLatitude = currentLocation.coordinate.latitude;
double tempLongitude = currentLocation.coordinate.longitude;
[sdkInstance setLatitude: tempLatitude];
[sdkInstance setLongitude: tempLongitude];

Version change log

Version 2.3

  • Bug fixes.

Version 2.2

  • Bug fixes.

Version 2.1

Notable Changes

  • Merged trackEvent & trackSale method into a single trackEvent method.
  • Efficiency improvements.

Version 2.0

  • Introduced location based tracking.
  • Developer can set latitude and longitude to SDK and can track for location specific installs.