Docs
SDK

Overview

The Layers SDK instruments your app for attribution and event tracking — install it once per platform, then track the events that matter. Available for Expo, React Native, iOS, Android, Flutter, Unity, Web, and Node.

View as Markdown

The Layers SDK instruments your app so Layers can attribute installs to the campaigns that drove them and measure what users do afterward. You install it once per platform, initialize it with your App ID, and call track() for the events you care about — the SDK handles sessions, batching, and attribution for you.

This is the client SDK — the code you ship inside your app. If you're building against Layers from a backend and want HTTP endpoints instead, see the API integration. If you can't ship a client SDK at all, you can forward events server-side with POST /v1/events.

Supported platforms

PlatformPackage
Expo@layers/expo
React Native@layers/react-native
iOS (Swift)layers-sdk-ios (Swift Package)
Android (Kotlin)io.layers.sdk:layers-android
Flutterlayers_flutter
Unity (C#)com.layers.analytics (UPM package, iOS and Android)
Web@layers/client
Node.js@layers/node

Get your App ID

Every install is initialized with an App ID — a stable identifier for one app in one project.

Ask for one in the Layers app: open Connections, choose Layers SDK, and press Get your App ID. The panel then hands you the value, along with a ready-to-paste prompt for your coding agent. The same App ID is returned by GET /v1/projects/:projectId/sdk-apps/:appId.

In the snippets throughout this section, replace YOUR_APP_ID with that value.

Your App ID is stable and there is only ever one per project — events and attributed clicks are keyed on it, so re-requesting returns the same value rather than minting a second one. If you decide against the SDK, Turn off the Events SDK in the same panel stops Layers counting it as a source. A build you have already shipped keeps reporting until you remove the SDK from it.

Next steps

Verify it's working

Once the SDK is initialized and sending data, confirm the signal on the same Events screen in the app — you'll see events stream in and a live status indicator. For a programmatic check (including an active synthetic probe), see SDK health & verification.

Automated install

If your project is connected to a GitHub repository, Layers can open the pull request that wires the SDK into your codebase for you. The manual steps in this section are what that pull request does.

You start it. On the Layers SDK row in your workspace, once GitHub is connected and a repository is attached, the button opens the pull request. Nothing runs on a schedule and nothing runs without the click.

What it needs before that button appears:

  • a repository attached to the project;
  • the Layers GitHub App installed on that repository's owner, with the repository granted to it (a read-only connection is not enough — the pull request is pushed with the App's own token);
  • an App ID issued for the project, which is what the generated initialization code uses.

What it does: clones your repository into a sandbox, detects the framework (Flutter, Expo, bare React Native, Swift, Kotlin or Unity), makes the smallest edits that install and initialize the SDK, pushes a new branch and opens a draft pull request against your default branch. Your default branch is never written to and nothing is merged for you — you review it like any other pull request.

If it cannot find an app it knows how to instrument, it changes nothing and opens nothing, and the row says so. Install by hand from the steps above.

On this page