Skip to main content
Add a native SDK to your app. It sends app_install, session_start, and session_end without more code.

Before you start

You need a write key from Settings → API, and a development build you can install on a clean device or simulator.
Do not load the web snippet inside a WebView as a replacement for an SDK. The web tracker gets a separate visitor_id and cannot read install attribution.

Install

In Xcode, open File → Add Package Dependencies. Add https://github.com/datalyr/swift. Add the DatalyrSDK product to your app target.
The SDK’s native modules are Expo modules. In bare React Native, you must install expo-modules-core (version 2.0.0 or later) and run npx install-expo-modules@latest. Without expo-modules-core, the app does not build. The install-expo-modules command adds use_expo_modules! to the Podfile and useExpoModules() to settings.gradle. Without it, the native modules never register.

Set up the rest

1

Initialize once, at launch

Put the call in your app entry point. The SDK ignores a second initialize(), so the first configuration stays in effect.
2

Send a screen event on navigation

Call screen(). It sends an event named pageview, not screen.
3

Identify after sign-in

Pass the same user ID your backend and billing provider use.
4

Pass every deep link to the SDK

On iOS, call handleDeepLink(url). React Native reads links on its own.
5

Pass identity to your subscription SDK

Before the paywall, register syncRevenueCatAttributes or syncSuperwallAttributes and, if the user is signed in, call identify(). Older SDKs: set the attributes yourself (see RevenueCat or Superwall). Optionally call bindProviderIdentity.
Call identify() once per signed-in person. A call with a different user ID runs reset() first, which rotates the anonymous ID and erases attribution and the journey.

Subscription revenue

Mobile purchases reach DATALYR through RevenueCat or Superwall, not the SDK. SDK trackPurchase values count as revenue only until the workspace has recorded revenue from a payment source or your server. See SDK values.
If you connect both RevenueCat and Superwall, one is your revenue source and the other is recorded at $0, so revenue is counted once. Choose which in Settings → General → Mobile revenue authority.

Web-to-app campaigns

A campaign that lands on a website before the App Store needs web tracking on the landing page as well.

Adding DATALYR to an app that already has users

When an update adds the SDK, existing users who open it are not new installs. From iOS SDK 2.2.0 and React Native SDK 1.8.0, the SDK checks on its first launch whether the app already ran on the device before. Those users send $sdk_first_launch_existing, not app_install. Conversion rules on app_install never send them to an ad platform as installs. Each of these events also carries detection_method and, when known, a coarse prior_install_age (for example 30-365d). Raw install dates never leave the device. Expect app_install to drop for a few days after the release, as the update reaches existing users. That drop is correct. If your app starts the SDK only after consent or login, pass existingUserHint. Your app knows from its own stored login or finished onboarding whether the person used it before:
The hint is read once, on the first SDK launch. Only true changes the result. Earlier SDK versions send app_install for every existing user who opens the update. If you shipped an earlier version into a live app, do not send app_install to an ad platform until users run 2.2.0 / 1.8.0.

Verify

  1. Delete the app, or reset the simulator.
  2. Launch a fresh install.
  3. Open Events in DATALYR.
  4. Confirm app_install and session_start arrive within 30 seconds.
  5. Open one screen. Confirm a pageview arrives.

When no event arrives

Next