The VouchrSDK allows tracking of analytics events via the <VOAnalyticsManagerProtocol>. The VouchrSDK doesn’t track any events itself, instead delegating back anytime an internal event is logged. See Analytics Events for a full list of events that are sent to the VOAnalyticsManagerProtocol.

To receive analytic events, do the following:

Have a class implement the VOAnalyticsManagerProtocol. Set the analyticsManager in VOEngine to your class.

Example Implementation with Google Analytics (Firebase)

Step 1.

@import Firebase;

// AnalyticsManager.h

@interface AnalyticsManager () <VOAnalyticsManagerProtocol>;

@end

// AnalyticsManager.m

@implementation AnalyticsManager

- (instancetype)init {
    self = [super init];
    if (self) {
        [self setup];
    }
    return self;
}

- (void)setup {
    NSString *firebaseConfigFilePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info-Alpha" ofType:@"plist"];
    FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:firebaseConfigFilePath];
    [FIRApp configureWithOptions:options];
}

#pragma mark <VOAnalyticsManagerProtocol>;

- (void)trackEvent:(NSString *)eventName withParams:(NSDictionary *)params {
    [FIRAnalytics logEventWithName:eventName parameters:params];
}

- (void)trackScreen:(NSString *)screenName screenClass:(Class)screenClass {
    [FIRAnalytics setScreenName:screenName screenClass:NSStringFromClass(screenClass)];
}

@end 
// AnalyticsManager.swift

import VouchrSDK
import Firebase

class AnalyticsManager: NSObject, VOAnalyticsManagerProtocol {

    override init() {
        super.init();
        setup()
    }

    func setup() {
        let firebaseConfigFilePath:String = Bundle.main.path(forResource: "GoogleService-Info-Alpha", ofType: "plist")!
        let options:FirebaseOptions = FirebaseOptions(contentsOfFile: firebaseConfigFilePath)!
        FirebaseApp.configure(options: options)
    }

    // MARK: - VOAnalyticsManagerProtocol
    
    func trackEvent(_ event: String!, withParams params: [AnyHashable : Any]!) {
        Analytics.logEvent(event, parameters: params as? [String : Any])
    }

    func trackScreen(_ screenName: String!, screenClass: AnyClass!) {
        Analytics.setScreenName(screenName, screenClass: NSStringFromClass(screenClass))
    }
    
}

Step 2.

AnalyticsManager *analtyicsManager = [AnalyticsManager new];
VOConfig *vouchrConfig = [VOConfig configWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"]];
self.vouchrEngineSDK = [VOEngine vouchrEngineWithConfig:vouchrConfig builder:^(VouchrEngineBuilder *builder) {
    builder.analyticsManager = analyticsManager;
    // other setup goes here
}]; 
let analyticsManager = AnalyticsManager()
self.vouchrSDK = VOEngine(config: vouchrConfig, builder: { (builder) in
    builder.analyticsManager = analyticsManager
    // other setup goes here
})