iOS

🧠 Note: If you plan to send events from your application, please contact us in order to fully utilize this feature.

Inloco provides an analytics solution to measure which places users visit the most. App Events allow these metrics to be tied with any event defined by your application, so it can report, for example, which places your application is most used or where they commonly perform an in-app purchase.

App Events have two components: Event and Properties. The Event defines which action you wish to track and the properties contain information about the action, allowing more customization for the events that are being recorded. Properties are defined in key-value pairs.

🧙Tips: Some events are automatically recorded, so you don't need to define them or implement custom logic to track them. Refer to the last section of this article for more details.

📡Recording custom events

In the following example, a custom event is recorded whenever the user performs a download and the file size can be set through properties.

After you've initialized the SDK, you can log an event by using the method trackEvent, passing the event name and a mapping of properties, as shown on the snippet below:

Objective-C
Swift
Objective-C
#import "AppDelegate.h"
@import InLocoSDK;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// app setup and SDK intialization goes here...
// Download is complete; trigger an app event.
NSString *eventName = @"file_download";
NSMutableDictionary *properties = [[NSMutableDictionary alloc] init];
[properties setObject:"file_id" forKey:@"id"];
[properties setObject:"png" forKey:@"file_type"];
[properties setObject:"5" forKey:@"file_size_mb"];
[ILMInLocoEvents trackEvent:eventName properties:properties];
return YES;
}
Swift
import InLocoSDK
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// app setup and SDK intialization goes here...
// Download is complete; trigger an app event.
let eventName = "file_download"
let properties = [
"id" : "file_id",
"file_type" : "png",
"file_size_mb" : "5"
]
ILMInLocoEvents.trackEvent(eventName, properties: properties)
return true
}
}

🧠Note: The properties parameter is optional; you can call trackEvent without including it. Passing an empty or null value to the eventName parameter, or a mapping of non-string key/values, does not send the event.

If the current location is relevant to the event, you can use the InLocoVisits.trackLocalizedEvent(); method. It works in the same way as trackEvent but tells the Inloco SDK to attach the current location to the event:

Swift
Objective-C
Swift
ILMInLocoEvents.trackLocalizedEvent("user_started_transaction")
Objective-C
[ILMInLocoEvents trackLocalizedEvent:@"user_started_transaction"];

🤖Automatically collected events

The following events can be automatically collected:

App Session

A session represents a single period of user interaction with your app. This information is automatically collected.

App Screen Session

A screen session represents a single period of user interaction with a specific Window (Activity or View Controller) inside the app.

It is initially disabled; to enable it, just modify the screenTrackingEnabled property on your Inloco options file.

InLocoOptions.plist (iOS)
InLocoOptions.plist (iOS)
// ... OTHER PROPERTIES
<!-->Indicates whether the SDK is allowed to track the user's screen navigation. Default value: false<-->
<key>screenTrackingEnabled</key>
<true/>