Storyly Analytics Setup

This guide covers the core concepts and a step-by-step implementation to help you initalize Storyly Analytics Module in your Android application.

📘

Before you begin

Make sure you have a working Storyly Placement SDK integration (token, view, provider) as described in the Initial Setup.

What is Storyly Analytics Module

Storyly Analytics Module is a lightweight module in Storyly Placement SDK for tracking product-related events (views, cart additions, wishlist additions, purchases) to enhance personalization in terms of product recommendation in Storyly content.

Setup SDK

Storyly Placement SDK integration covers the Storyly Analytics Module setup.

Initialize Components

You need to call STRAnalytics.initialize(config:) once in your application initialization, Application.onCreate().

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        val config = STRAnalyticsConfig.Builder()
            .setUserId(<end-user's id in your application>) // optional
            .build(token = <your_application_token_here>)
        STRAnalytics.initialize(this, config)
    }
}

🚧

Warning

Please provide a valid token during 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 = STRAnalyticProductEvent.Purchased,
  product = product
)

//STRAnalytics.track(
//    productEvent: STRAnalyticProductEvent,
//    products: List<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.

EventDescription
PDPViewedAn user viewed a product detail page
CartAddedAn user added a product to their cart
WishlistAddedA user added a product to their wishlist
PurchasedA user purchased a product

📘

Tip

Please check STRAnalyticProductEvent class reference.

📘

Best Practices

  • You must initialize STRAnalytics with correct configuration.