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. Categories, automatic events, Fragment and iOS screens need web 1.5.0 or Android, KMP and Flutter 0.4.0.New to the categories, automatic $ events and recommended names? Start with the event model.
Examples
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 measuring. category is optional (0.4.0+).Codeskop.track("added_to_cart", mapOf("product_id" to "sku-42", "price" to 1200, "currency" to "KES"))Codeskop.track("login_failed", mapOf("reason" to "invalid_password"), category = "identity") // Screens: Activities and Fragments are automatic. Name one yourself:Codeskop.screen("ProductDetails")import CodeskopSDK Codeskop.shared.identify(userId: user.id, traits: ["plan": user.plan])Codeskop.shared.track(name: "added_to_cart", properties: ["product_id": "sku-42", "price": 1200])Codeskop.shared.track(name: "login_failed", properties: ["reason": "invalid_password"], category: "identity") // View controllers are automatic. Name a SwiftUI view yourself:Codeskop.shared.screen(name: "ProductDetails", properties: [:])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.track('login_failed', properties: {'reason': 'invalid_password'}, category: 'identity');await Codeskop.screen('ProductDetails'); // for routes without a nameimport { 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" });track("login_failed", { reason: "invalid_password" }, { category: "identity" }); // 1.5.0+// Page views, including client-side navigation, are recorded automatically.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?, category?) | n/a | A custom event: something a user did. Use snake_case, object first, verb in the past tense: order_completed, video_played. Names starting with $ are reserved and dropped. |
| screen(name, properties?) | n/a | A screen or page view. Recorded automatically on web, for Android Activities and Fragments, iOS view controllers and 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. |
The category
Pass a category to say what kind of step an event is: interaction, identity, conversion, navigation or lifecycle. Without one, Codeskop works it out from the name (login_ and signup_ names are identity, everything else is conversion). An unknown value is dropped with a warning and the event is still sent.
| Option | Type | Description |
|---|---|---|
| Web & React | 1.5.0+ | track(name, properties, { category: "identity" }). TypeScript exports TrackCategory and TrackOptions. |
| Android & KMP | 0.4.0+ | Codeskop.track(name, properties, category = "identity") |
| iOS (Swift) | 0.4.0+ | Codeskop.shared.track(name:properties:category:) |
| Flutter | 0.4.0+ | Codeskop.track(name, properties: {…}, category: 'identity') |
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 events
The SDKs also send events of their own, with names that start with $: the app or tab opening and going to the background, sessions starting and ending, app updates, and on the web, deep links and clicks. Lifecycle events are recorded on every plan and never count toward the analytics meter. The full list, with their properties, is in the event model.
- Web clicks are on by default where your plan allows them. Turn them off with
autocapture: { clicks: false }, and skip an element withdata-codeskop-ignore(details). - Android, iOS and Flutter don't record taps. Track the ones that matter with the
interactioncategory.
Automatic screens
| Option | Type | Default | Description |
|---|---|---|---|
| Android | captureScreens | true | Each Activity shown is a screen, named after its class (CheckoutActivity). From 0.4.0, Fragments with a view are too, when your app uses androidx.fragment. |
| iOS | captureScreens | true | From 0.4.0, each UIViewController shown is a screen, named after its class. Navigation, tab and SwiftUI hosting controllers are skipped. |
| 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. |
Jetpack Compose apps record each navigation destination with one call (0.4.0+). It names screens by route, so product/{id} stays one screen. It needs androidx.navigation, which Compose navigation apps already have.
import com.codeskop.sdk.android.trackNavigation val navController = rememberNavController()LaunchedEffect(navController) { Codeskop.trackNavigation(navController) }Screens also carry previous_screen, and load_ms where the SDK can measure how long the screen took to show.
Sessions
One rule on every platform: a session ends after 30 minutes without activity. Screens and events in a session are linked, which is how paths and time on screen work. Every event carries the session id, errors and API calls included.
- On Android and iOS (0.4.0+), the session is saved on the device, so reopening the app within 30 minutes continues it.
- On the web, a session continues across page loads in the same tab, and closing the tab ends it.
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. |