ConvivaAppAnalytics 1.0.3

ConvivaAppAnalytics 1.0.3

Maintained by Butchi Peddi, Sandeep Madineni, Shubham Gupta.



  • By
  • Conviva

conviva-ios-appanalytics

Use Application Analytics to autocollect events and track application specific events and state changes.

Initialization

  • SPM

  • Cocoapods

    • Add below line in pods file
      • pod 'ConvivaAppAnalytics', '0.2.15'
  • Manual Download

    • Download and unzip the package from Downloads. During the build phase, add ConvivaAppAnalytics.xcframework to Link Binary with Libraries section in xcode. This package contains the frameworks for both, iOS and tvOS.
  • Link the following system frameworks to Link Binary with Libraries section in xcode:

    • UIKit
    • Foundation
    • CoreTelephony (iOS only)
    • FMDB (version 2.7 or above)
    • In Other Linker Flags section in Xcode, add "-ObjC".
    • To refer to the Conviva classes from your source code, add the following import statements:
* Swift:
import ConvivaAppAnalytics
* ObjC:
@import ConvivaAppAnalytics;

Initialize the top level object

* Swift:
var tracker = CATAppAnalytics.createTracker(customerKey: customerKey, appName: appName)
* ObjC:
id<CATTrackerController> tracker = [CATAppAnalytics createTrackerWithCustomerKey:customerKey appName:appName];

customerKey - a string to identify specific customer account. Different keys shall be used for development / debug versus production environment. Find your keys on the account info page in Pulse.

appName - a string value used to distinguish your applications. Simple values that are unique across all of your integrated platforms work best here.

Set the user id (viewer id)

* Swift:
tracker?.subject?.userId = "user_id"
* ObjC:
tracker.subject.userId = @"user_id";

Custom event tracking to track your application specific events and state changes

Use trackCustomEvent() to track all kinds of events. This API provides 2 fields to describe the tracked events.

  • eventName - Name of the custom event.
  • eventData – Any type of data in string format.

The following example shows the implementation of the 'onClick' event listener to any element:

* Swift:
let data = "{\"identifier1\": \"test\",\"identifier2\": 1,\"identifier3\":true}"
tracker?.trackCustomEvent("your-event-name", data: data)
* ObjC:
NSString *data = @"{\"identifier1\": \"test\",\"identifier2\": 1,\"identifier3\":true}";
[tracker trackCustomEvent:@"your-event-name" data:data];

Screen view tracking

When user navigates between screens, user journey is tracked by reading the class names of UIViewController classes. Name of the screens can be customized using below code as per the bussiness needs.

* Swift:
* //Add below property in view controller
* @objc var catViewId:String = "App Analytics View"
* ObjC:
* //Declare property like below
* @property(copy, nonatomic)NSString *catViewId;
* //Add below line in viewDidLoad method
* self.catViewId = @"Customizable name";

Custom Tags Support

Support is added to pass custom data as key-val pairs which are available in each event triggered by sdk and passed to backend. Below are the new api additions to support Custom Tags.

* ObjC:
// Setter API

/**
 * Set custom tags.
 * Pass custom tags
 * @param tags Dictionary of Key-Val pairs.
 */
- (void)setCustomTags:(NSDictionary *)tags;

//Usage
NSDictionary* tags = @{
    @"Key1": @"Value1",
    @"Key2": @"Value2",
};
[tracker setCustomTags:tags];

// Clear API
/**
 * Clears all custom tags.
 */
- (void)clearCustomTags;

//Usage
[tracker clearCustomTags];

/**
 * Clears custom tags which are matching keys as passed in.
 * Keys of tags to be cleared
 * @param tagKeys tagKeys.
 */
- (void)clearCustomTags:(NSArray *)tagKeys;

//Usage
NSArray* keys = @[ @"Key1", @"Key2", @"Key3" ];
[tracker clearCustomTags:keys];
* Swift:
//Usage: Set custom tags
let tags = ["Key1": "Value1", "Key2": "Value2"]
tracker?.setCustomTags(tags)

//Usage: Clear all custom tags
tracker?.clearCustomTags()

//Usage: Clear custom tags
let keys = ["Key1", "Key2", "Key3"]
tracker?.clearCustomTags(keys)

Note: If user of this sdk also uses ConvivaSDK for Experience Insights/Ad Insights, ConvivaSDK version must be 4.0.28 or above to be compatable with ConvivaAppAnalytics version 0.2.3 or above

To enable automatic collection of playback events, ConvivaSDK 4.0.32 or above must be used.