Mobile

Our iOS, Android, React Native and Flutter SDKs. Install, init with a Project token, track screens and events, identify, and what a mobile event looks like on the wire.

Mobile tracking uses our own SDKs, one per platform, all built on the same ingest contract as the browser SDK: a Project token, an offline queue, batching inside the service's ceilings, and the same identity calls. Nothing on this page depends on a third-party analytics vendor.

At a glance

A Project token is the right credential for a shipped app: it is write-only and is rejected on every route that returns data, so extracting it from a binary gains nothing but the ability to send events. Never ship a Server key (ipa_sec_…) in an app; keep it on your own server with the Node SDK.

Note

None of the four packages is published to a registry yet; publishing is a human release step. The Swift package compiles and its tests pass. The React Native package's tests pass. The Android and Flutter packages were written against the contract but have not been compiled on the machine that wrote them. Until they are published, add them from the repository path and treat the first build as part of your review.

iOS and macOS (Swift)

In Package.swift, or in Xcode with File → Add Package Dependencies…:

dependencies: [
    .package(url: "https://github.com/intelligent-page/analytics-swift.git", from: "0.1.0"),
]
import IntelligentPageAnalytics

// once, at start-up
Analytics.configure(token: "ipa_pub_REPLACE_ME")

Analytics.shared.screen("Checkout")                                  // $pageview, and `path` on later events
Analytics.shared.track("Signup Started", properties: ["plan": "starter", "seats": 3])
Analytics.shared.identify("user_1024", traits: ["email": "ada@example.com"])
Analytics.shared.alias("legacy-42")                                  // a second id for the same person
Analytics.shared.group("company", "acme-inc", traits: ["name": "Acme"])
Analytics.shared.register(["app_version": "2.1.0"])                  // on every later event
Analytics.shared.people.set(["plan": "growth"])                      // profile update
Analytics.shared.flush()
Analytics.shared.reset()                                             // sign-out: a fresh visitor

Property values are String, Int, Double, Bool or nil. The service drops anything that is not a scalar, so the typed API turns a nested dictionary into a compile error instead of an event that silently loses a property.

Android (Kotlin)

dependencies {
    implementation("page.intelligent:analytics-android:0.1.0")
}

The library declares one permission, INTERNET, and merges it into your manifest.

import page.intelligent.analytics.Analytics
import page.intelligent.analytics.props

class App : Application() {
    override fun onCreate() {
        super.onCreate()
        Analytics.configure(this, token = "ipa_pub_REPLACE_ME")
    }
}

Analytics.screen("Checkout")                                        // $pageview, and `path` on later events
Analytics.track("Signup Started", props("plan" to "starter", "seats" to 3))
Analytics.identify("user_1024", props("email" to "ada@example.com"))
Analytics.alias("legacy-42")
Analytics.group("company", "acme-inc", props("name" to "Acme"))
Analytics.register(props("app_version" to "2.1.0"))
Analytics.people.set(props("plan" to "growth"))
Analytics.flush()
Analytics.reset()

React Native

npm install @intelligent-page/analytics-react-native
# recommended, so ids and unsent events survive a relaunch:
npm install @react-native-async-storage/async-storage

Expo: npx expo install @react-native-async-storage/async-storage. The package never imports react-native or AsyncStorage itself; you pass them in, which is what keeps it usable in Jest and on the server half of an Expo universal app.

// analytics.ts
import AsyncStorage from '@react-native-async-storage/async-storage';
import { AppState, Platform } from 'react-native';
import { createAnalytics } from '@intelligent-page/analytics-react-native';

export const analytics = createAnalytics({
  token: 'ipa_pub_REPLACE_ME',
  storage: AsyncStorage,   // ids + offline queue across launches
  appState: AppState,      // flush before the OS suspends the app
  context: { app_version: '2.1.0', $os: Platform.OS },
  locale: 'en-GB',
});

analytics.screen('Home');                                   // $screen, and `path` on later events
analytics.track('Signup Started', { plan: 'starter' });
analytics.identify('user_1024', { email: 'ada@example.com' });
analytics.alias('legacy-42');
analytics.group('company', 'acme-inc', { name: 'Acme' });
analytics.register({ experiment: 'checkout-b' });           // on every later event, persisted
analytics.people.set({ plan: 'growth' });
analytics.flush();
analytics.reset();

Flutter and Dart

# pubspec.yaml
dependencies:
  intelligent_page_analytics:
    path: ../packages/analytics-flutter   # until it is published
  shared_preferences: ^2.2.0              # recommended: ids and the queue survive a relaunch
import 'package:intelligent_page_analytics/intelligent_page_analytics.dart';

final analytics = Analytics(
  token: 'ipa_pub_REPLACE_ME',
  storage: SharedPreferencesStorage(),   // from example/flutter_adapters.dart
  lifecycle: lifecycleBridge.stream,     // idem: flush when the app goes to the background
  context: <String, Object?>{'app_version': '2.1.0'},
);

analytics.screen('Home');
analytics.track('Signup Started', {'plan': 'starter'});
analytics.identify('user_1024', {'email': 'ada@example.com'});
analytics.alias('legacy-42');
analytics.group('company', 'acme-inc', {'name': 'Acme'});
analytics.register({'experiment': 'checkout-b'});
analytics.peopleSet({'plan': 'growth'});
await analytics.flush();
analytics.reset();

peopleSet is named that way because set is a Dart built-in identifier; it sends the same $set profile update as the other SDKs.

What a mobile event looks like

Every SDK sends the ingest contract's short field names, so a mobile event and a web event sit in the same table and the same reports.

Every SDK holds events in memory and mirrors them to device storage, then sends in batches of at most 50 events and 64 KB (the service's ceiling), on a size or time trigger well below it. A failed send is retried on a short ladder and, if the device stays offline, delivered on the next launch rather than lost. Each event carries a unique id, so a retry that already landed is ignored by the service and never counts twice.

With consent withheld (consent: false, or a function returning false in React Native) the SDK sends nothing and writes nothing to the device. Grant it later with setConsent(true) and tracking starts from that moment.

reset() on sign-out discards the user id and anonymous id and starts a fresh visitor, which is the right call on a shared device.

Verify

curl -N https://t.intelligent.page/v1/live \
  -H 'Authorization: Bearer ipa_sec_REPLACE_ME'

Run the app on a device or simulator with that stream open and call flush() explicitly: the SDKs batch on a timer, so nothing appears for up to ten seconds otherwise. The event should show source: "mobile" and the $lib of the SDK you shipped.

Next