Skip to content

Track events & screens

Three calls cover it: track for what users do, screen for where they are, and identify for who they are. Screens are recorded for you.

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

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 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")

The three calls

OptionTypeDescription
track(name, properties?, category?)n/aA 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/aA screen or page view. Recorded automatically on web, for Android Activities and Fragments, iOS view controllers and named Flutter routes.
identify(userId, traits?)n/aWho 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.

OptionTypeDescription
Web & React1.5.0+track(name, properties, { category: "identity" }). TypeScript exports TrackCategory and TrackOptions.
Android & KMP0.4.0+Codeskop.track(name, properties, category = "identity")
iOS (Swift)0.4.0+Codeskop.shared.track(name:properties:category:)
Flutter0.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 null removes 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 with data-codeskop-ignore (details).
  • Android, iOS and Flutter don't record taps. Track the ones that matter with the interaction category.

Automatic screens

OptionTypeDefaultDescription
AndroidcaptureScreenstrueEach 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.
iOScaptureScreenstrueFrom 0.4.0, each UIViewController shown is a screen, named after its class. Navigation, tab and SwiftUI hosting controllers are skipped.
FlutterCodeskopNavigatorObserveradd itEach named route pushed (and the route shown again on back) is a screen.
Web & ReactcapturePageViewstrueThe 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.

Compose navigation
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.

Use these names and Codeskop's funnels read naturally, for example a purchase funnel of the four steps below.

OptionTypeDescription
product_viewedproduct_id, price, currency, categoryA product page or card was opened.
added_to_cartproduct_id, price, quantityAn item was added to the cart.
checkout_startedvalue, currency, itemsThe user began checkout.
order_completedorder_id, value, currency, payment_methodPayment succeeded. Use value for revenue.
signed_up / logged_inmethodAccount events, e.g. method: phone, google.

Next steps

Product analytics overview