iOS native application instrumentation

,

Installation

The installation is done through Cocoapods, adding the following line to the Podfile file:

pod 'CompassSDK', '~> 1'

Configuration
To use the library you should add the account ID provided by Compass when you registered. Within the file Info.plist, add the following properties:

<key>COMPASS_ACCOUNT_ID</key>
<integer>0</integer>
<key>COMPASS_ENDPOINT</key>
<string>https://events.newsroom.bi/</string>

Usage
To be able to use the library, import the CompassSDK module:

import CompassSDK

All the library functionalities are done through the CompassTracker class. To access CompassTracker, use the shared variable in any part of the application

let tracker = CompassTracker.shared

Page Tracking
CompassTracker automatically counts the time the user stays on a page. If you want to start tracking a specific page use the method startPageView, indicating the URL of a page.

`tracker.startPageView(url: {URL})`

CompassTracker will keep counting the time on page until a new call is made to startPageView with a different URL. In alternative, you can instruct Compass to stop tracking through the method stopTracking()

tracker.stopTracking()

Scroll tracking
If you want to count the scroll percentage of a user on a page, indicate in the startPageView method the UIScrollView

tracker.startPageView(url: {URL}, scrollView: {UIScrollView}})`

User identification
To associate the app user to the records generated by the library, use the method serUserId, indicating the user ID in your platform.

tracker.setUserId({USER_ID})

Additionally, you can indicate the user type. Currently the library allos the types ‘logged’ and ‘paid’. To indicate the user type, use the method setUserType

tracker.setUserType(.logged)
tracker.setUserType(.paid)

It’s recommended that you indicate the ID and the user type before doing starting to track the user identification.

RFV
If you want to obtain the Compass RFV code, use the method getRFV. This method returns the RFV code within a handler

tracker.getRFV { rfv in
//Returned rfv management
}

Conversion tracking
If you want to track a conversion, you can call the method track(conversion: String):

tracker.track(conversion: "{CONVERSION}"