Analytics SDK
This guide covers the core concepts and a step-by-step implementation to help you initialize Storyly Analytics SDK - Personalization Engine and Conversion Tracking Module in your iOS application.
Before you begin
Make sure you have a working Storyly Placement SDK integration as described in the Initial Setup.
What is Storyly Analytics Module
Storyly Analytics Module is a lightweight module in the Storyly Placement SDK that tracks product-related events in your app: product views, cart additions, wishlist additions and purchases. These events power two features:
- Personalization: product recommendations in Storyly content, based on what each user views and buys.
- Conversion tracking: connecting purchases to the Storyly content users saw, so you can measure the revenue your content influences.
Setup SDK
Storyly Placement SDK integration covers the Storyly Analytics Module setup.
Import Module
You need to import related modules to use Storyly Analytics Module.
import StorylyAnalytics
Initialize Components
You need to call STRAnalytics.initialize(config:) once in your application initialization, AppDelegate.application(_:didFinishLaunchingWithOptions:).
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
let analyticsConfig = STRAnalyticsConfig.Builder()
.setUserId(<end-user's id in your application>) // optional
.build(token: <your_application_token_here>)
STRAnalytics.initialize(config: config)
return true
}
Warning
Please provide a valid
tokenduring initialization, otherwise the events are silently dropped.
Track Events
You can track product interactions anywhere in your application.
let product = STRAnalyticProduct(
productId: ...,
productGroupId: ...,
title: ...,
desc: ...
price: ...,
salesPrice: ...
)
STRAnalytics.track(productEvent: .Purchased, product: product)
// STRAnalytics.track(productEvent: STRAnalyticProductEvent, products: [STRAnalyticProduct])
Tip
Please check STRAnalytics class reference.
Tip
Please check STRAnalyticProduct class reference.
Product Analytic Events
This section shows the list of product analytic events and their description.
| Event | Description |
|---|---|
| PDPViewed | An user viewed a product detail page |
| CartAdded | An user added a product to their cart |
| WishlistAdded | A user added a product to their wishlist |
| Purchased | A user purchased a product |
Tip
Please check STRAnalyticProductEvent class reference.
Best Practices
- You must initialize
STRAnalyticswith correct configuration.
Updated 3 days ago

