Analytics
The OWAnalytics
protocol in the OpenWeb iOS SDK allows you to track analytics events and set custom business intelligence data.
public protocol OWAnalytics {
var customBIData: OWCustomBIData { get set }
func addBICallback(_ callback: @escaping OWBIAnalyticEventCallback)
}
With a callback, you can handle specific analytics events, allowing you to integrate with your BI or analytics systems.
var manager: OWManagerProtocol = OpenWeb.manager
// Analytics
var analytics: OWAnalytics = OpenWeb.manager.analytics
// Set custom BI
let data: OWCustomBIData = ...
analytics.customBIData = data
// Set callback for the events
let analyticClosure: OWBIAnalyticEventCallback = { event, additionalInfo, postId in
switch element {
case .sortTypeChanged(let type):
// Send your own BI/analytics here
case .default:
break
}
}
analytics.addBICallback(analyticBIClosure) // Allow multiple callbacks
Enumerations and Structs
OWBIAnalyticEvent
Setting | Description |
---|---|
OWBIAnalyticEvent OWBIAnalyticEvent | Analytics event
Possible Values:
|
OWBIAnalyticEventCallback
public typealias OWBIAnalyticEventCallback = (
event: OWBIAnalyticEvent,
additionalInfo: OWBIAnalyticAdditionalInfo,
postId: String
) -> Void
Argument | Description |
---|---|
additionalInformation OWBIAnalyticAdditionalInfo | Custom data defined by the publisher in customBIData
|
event OWBIAnalyticEvent | Subset of a triggered event
See: OWBIAnalyticEvent |
postId string | Unique article identifier that is specific to the article page
The ideal postId has the following characteristics:
|
OWCustomBIData
Custom data defined by the publisher
typealias OWCustomBIData = [String: Codable]
Updated 11 months ago