SDK versions
Product analytics needs Android and Flutter 0.3.0 or later, and@codeskop/tracker / @codeskop/tracker-react 1.3.0 or later, on a Growth or Scale plan. On other plans these calls do nothing.Examples
Kotlin
import com.codeskop.sdk.core.Codeskop // After login, and on launch when a user is already signed inCodeskop.identify(user.id, mapOf("plan" to user.plan, "city" to user.city)) // Anything worth measuringCodeskop.track("added_to_cart", mapOf("product_id" to "sku-42", "price" to 1200, "currency" to "KES")) // Screens: Activities are automatic. For Compose / fragments:Codeskop.screen("ProductDetails")Dart
import 'package:codeskop_tracker/codeskop_tracker.dart'; MaterialApp( navigatorObservers: [CodeskopNavigatorObserver()], // named routes become screens // ...); await Codeskop.identify(user.id, traits: {'plan': user.plan});await Codeskop.track('added_to_cart', properties: {'product_id': 'sku-42', 'price': 1200});await Codeskop.screen('ProductDetails'); // for routes without a nameTypeScript
import { identify, track } from "@codeskop/tracker"; identify(user.id, { plan: user.plan, city: user.city });track("added_to_cart", { product_id: "sku-42", price: 1200, currency: "KES" });// Page views, including client-side navigation, are recorded automatically.React
import { useCodeskop } from "@codeskop/tracker-react"; function AddToCart({ product }: { product: Product }) { const { track } = useCodeskop(); return <button onClick={() => track("added_to_cart", { product_id: product.id, price: product.price })}>Add to cart</button>;}The three calls
| Option | Type | Description |
|---|---|---|
| track(name, properties?) | n/a | A custom event: something a user did. Use snake_case verbs in the past tense: order_completed, video_played. |
| screen(name, properties?) | n/a | A screen or page view. Recorded automatically on web, for Android Activities and for named Flutter routes. |
| identify(userId, traits?) | n/a | Who the user is: your own id, plus optional traits (plan, city, signup_source…). Traits show on the user's profile and can be used in segments. |
Properties and traits
- Values can be text, numbers, true/false, null, or lists of those. Nested objects are dropped.
- Up to 100 properties per event; text is cut at 1,024 characters; names at 128.
- Don't send names, emails or phone numbers; values that look like an email or phone number are replaced with
[REDACTED]. Use your own ids instead. - A trait set to
nullremoves it from the profile.
Automatic screens
| Option | Type | Default | Description |
|---|---|---|---|
| Android | captureScreens | true | Each Activity shown is a screen, named after its class (CheckoutActivity). |
| Flutter | CodeskopNavigatorObserver | add it | Each named route pushed (and the route shown again on back) is a screen. |
| Web & React | capturePageViews | true | The first page and every navigation (pushState, back/forward, hash changes). Path only, no query strings. |
Single-Activity Android apps (Jetpack Compose) record destinations with a navigation listener:
Compose navigation
navController.addOnDestinationChangedListener { _, destination, _ -> destination.route?.let { Codeskop.screen(it) }}Sessions
A session lasts while the app or tab is in use and ends after 30 minutes without activity. Screens and events in a session are linked, which is how paths and time on screen work. On the web, a session continues across page loads in the same tab.
Recommended events for e-commerce
Use these names and Codeskop's funnels read naturally, for example a purchase funnel of the four steps below.
| Option | Type | Description |
|---|---|---|
| product_viewed | product_id, price, currency, category | A product page or card was opened. |
| added_to_cart | product_id, price, quantity | An item was added to the cart. |
| checkout_started | value, currency, items | The user began checkout. |
| order_completed | order_id, value, currency, payment_method | Payment succeeded. Use value for revenue. |
| signed_up / logged_in | method | Account events, e.g. method: phone, google. |