Analytics
The Nutrient Analytics API allows you to easily collect usage data based on a user’s activity taking place in Nutrient components.
The Nutrient Analytics API consists of:
-
A
PDFAnalytics
object that you can access through a shared Nutrient instance -
A
PDFAnalyticsClient
protocol that you need to implement to capture analytics events
Integration
The Nutrient Analytics API comes bundled with PSPDFKitUI.xcframework
, so you don’t need to add any external packages. Just ensure you’re importing the PSPDFKitUI
module in your file wherever you’re using this API.
Enable analytics
The PSPDFKit Analytics API is disabled by default, so you first need to enable it to use it:
PSPDFKit.SDK.shared.analytics.enabled = true
PSPDFKitGlobal.sharedInstance.analytics.enabled = YES;
Next, you need to implement the PDFAnalyticsClient
protocol. Your PDFAnalyticsClient
is a place to process Nutrient events and pass them to the analytics service of your choice.
Be aware that events are delivered on a background queue.
Create an instance of your PDFAnalyticsClient
when the app launches (preferably at the same time you’re configuring the Nutrient license) and register it with PDFAnalytics
:
let analyticsClient = YourAnalyticsClient() PSPDFKit.SDK.shared.analytics.add(analyticsClient)
id<PSPDFAnalyticsClient> analyticsClient = [[YourAnalyticsClient alloc] init]; [PSPDFKitGlobal.sharedInstance.analytics addAnalyticsClient:analyticsClient];
You can find a simple PDFAnalyticsClient
implementation in AnalyticsClientExample.swift
in the Nutrient Catalog app.