Docs
SDK

Prompt your coding agent

A ready-to-paste prompt that instructs Claude, Cursor, or any coding agent to install and instrument the Layers SDK in your app — install, initialize, and track the events that matter.

View as Markdown

Rather than wiring the SDK by hand, hand this prompt to a coding agent — Claude Code, Cursor, or any AI assistant working in your repo. It carries the install steps, initialization, and the events worth tracking, so the agent can instrument your app in one pass.

Before you paste: replace YOUR_APP_ID with your App ID (Layers app → your project's Events screen → gear → App ID; see Get your App ID). Pick your platform's tab below and copy the whole block.

I need to integrate the Layers SDK into my Expo app. Here are my credentials:

App ID: YOUR_APP_ID

## Installation

## 1. Install dependencies
```
npm install @layers/expo @layers/react-native expo-tracking-transparency expo-linking
```

## 2. Add the plugin to app.json (under expo.plugins)
```
{
  "expo": {
    "plugins": [
      ["@layers/react-native/plugin", {
        "ios": { "attUsageDescription": "Helps show personalized content." },
        "enableDebug": true
      }]
    ]
  }
}
```

## 3. Initialize and track events
```
import { LayersReactNative } from '@layers/expo';

const layers = new LayersReactNative({
  appId: 'YOUR_APP_ID',
  enableDebug: __DEV__,
});

useEffect(() => {
  layers.init();
}, []);

layers.track('purchase_success', { product_id: 'premium', revenue: 9.99 });
```

## What to implement

1. **Initialize the SDK** at app startup (see the initialization code above).
2. **Track key events:**
   - `app_open` — when the app launches
   - `sign_up` — when a user creates an account
   - `login` — when a user logs in
   - `purchase_success` — when a purchase completes (include: product_id, revenue, currency, transaction_id)
   - `subscription_start` — when a subscription begins
   - `trial_start` — when a free trial starts
   - Any custom events relevant to my app
3. **Set user properties** after authentication:
   - User ID (via identify/setUserId)
   - Subscription tier, signup date, etc.
4. **Handle deep links** (if applicable):
   - Configure URL schemes and universal links
   - Forward deep link events to the SDK
5. **iOS only — App Tracking Transparency:**
   - Request ATT permission after onboarding
   - The SDK handles IDFA collection automatically after consent

## Event properties
Always include relevant properties with events:
- `revenue` and `currency` for purchase events
- `product_id` for product-related events
- `transaction_id` for purchase verification

## Important notes
- The SDK auto-tracks sessions and app lifecycle events
- Events are queued and batched automatically (flush every 30s or 20 events)
- Enable debug logging during development to see event logs (Expo and React Native: `enableDebug: __DEV__`)
- The SDK handles attribution automatically — no additional setup needed

Please implement this SDK integration in my codebase, following the patterns and architecture already established in my project.
I need to integrate the Layers SDK into my React Native app. Here are my credentials:

App ID: YOUR_APP_ID

## Installation

## 1. Install dependencies
```
npm install @layers/react-native @react-native-community/netinfo @react-native-async-storage/async-storage
cd ios && pod install
```

## 2. Initialize and track events
```
import { LayersReactNative } from '@layers/react-native';

const layers = new LayersReactNative({
  appId: 'YOUR_APP_ID',
  enableDebug: __DEV__,
});

useEffect(() => {
  layers.init();
}, []);

layers.track('purchase_success', { product_id: 'premium', revenue: 9.99 });
```

## What to implement

1. **Initialize the SDK** at app startup (see the initialization code above).
2. **Track key events:**
   - `app_open` — when the app launches
   - `sign_up` — when a user creates an account
   - `login` — when a user logs in
   - `purchase_success` — when a purchase completes (include: product_id, revenue, currency, transaction_id)
   - `subscription_start` — when a subscription begins
   - `trial_start` — when a free trial starts
   - Any custom events relevant to my app
3. **Set user properties** after authentication:
   - User ID (via identify/setUserId)
   - Subscription tier, signup date, etc.
4. **Handle deep links** (if applicable):
   - Configure URL schemes and universal links
   - Forward deep link events to the SDK
5. **iOS only — App Tracking Transparency:**
   - Request ATT permission after onboarding
   - The SDK handles IDFA collection automatically after consent

## Event properties
Always include relevant properties with events:
- `revenue` and `currency` for purchase events
- `product_id` for product-related events
- `transaction_id` for purchase verification

## Important notes
- The SDK auto-tracks sessions and app lifecycle events
- Events are queued and batched automatically (flush every 30s or 20 events)
- Enable debug logging during development to see event logs (Expo and React Native: `enableDebug: __DEV__`)
- The SDK handles attribution automatically — no additional setup needed

Please implement this SDK integration in my codebase, following the patterns and architecture already established in my project.
I need to integrate the Layers SDK into my iOS (Swift) app. Here are my credentials:

App ID: YOUR_APP_ID

## Installation

## 1. Add the Swift Package
```
// Package.swift
.package(url: "https://github.com/layers/layers-sdk-ios.git", from: "1.0.0")
```

## 2. Initialize and track events
```
import Layers

Layers.initialize(config: LayersConfig(
    appId: "YOUR_APP_ID",
    environment: .production
))

Layers.track("purchase_success", properties: ["product_id": "premium", "revenue": 9.99])
```

## What to implement

1. **Initialize the SDK** at app startup (see the initialization code above).
2. **Track key events:**
   - `app_open` — when the app launches
   - `sign_up` — when a user creates an account
   - `login` — when a user logs in
   - `purchase_success` — when a purchase completes (include: product_id, revenue, currency, transaction_id)
   - `subscription_start` — when a subscription begins
   - `trial_start` — when a free trial starts
   - Any custom events relevant to my app
3. **Set user properties** after authentication:
   - User ID (via identify/setUserId)
   - Subscription tier, signup date, etc.
4. **Handle deep links** (if applicable):
   - Configure URL schemes and universal links
   - Forward deep link events to the SDK
5. **App Tracking Transparency:**
   - Request ATT permission after onboarding
   - The SDK handles IDFA collection automatically after consent

## Event properties
Always include relevant properties with events:
- `revenue` and `currency` for purchase events
- `product_id` for product-related events
- `transaction_id` for purchase verification

## Important notes
- The SDK auto-tracks sessions and app lifecycle events
- Events are queued and batched automatically (flush every 30s or 20 events)
- The SDK handles attribution automatically — no additional setup needed

Please implement this SDK integration in my codebase, following the patterns and architecture already established in my project.
I need to integrate the Layers SDK into my Android (Kotlin) app. Here are my credentials:

App ID: YOUR_APP_ID

## Installation

## 1. Add the dependency
```
// build.gradle.kts
implementation("io.layers.sdk:layers-android:2.0.0-alpha.1")
```

## 2. Initialize and track events
```
// Application.onCreate()
LayersAndroid.configure(this) {
    appId = "YOUR_APP_ID"
    environment = Environment.PRODUCTION
}

LayersAndroid.track("purchase_success", mapOf("product_id" to "premium", "revenue" to 9.99))
```

## What to implement

1. **Initialize the SDK** at app startup (see the initialization code above).
2. **Track key events:**
   - `app_open` — when the app launches
   - `sign_up` — when a user creates an account
   - `login` — when a user logs in
   - `purchase_success` — when a purchase completes (include: product_id, revenue, currency, transaction_id)
   - `subscription_start` — when a subscription begins
   - `trial_start` — when a free trial starts
   - Any custom events relevant to my app
3. **Set user properties** after authentication:
   - User ID (via identify/setUserId)
   - Subscription tier, signup date, etc.
4. **Handle deep links** (if applicable):
   - Configure URL schemes and app links
   - Forward deep link events to the SDK
5. **Attribution:** Android uses Install Referrer automatically — no extra setup.

## Event properties
Always include relevant properties with events:
- `revenue` and `currency` for purchase events
- `product_id` for product-related events
- `transaction_id` for purchase verification

## Important notes
- The SDK auto-tracks sessions and app lifecycle events
- Events are queued and batched automatically (flush every 30s or 20 events)
- The SDK handles attribution automatically — no additional setup needed

Please implement this SDK integration in my codebase, following the patterns and architecture already established in my project.
I need to integrate the Layers SDK into my Flutter app. Here are my credentials:

App ID: YOUR_APP_ID

## Installation

## 1. Add the dependency
```
# pubspec.yaml
dependencies:
  layers_flutter: ^0.1.0
```

## 2. Initialize and track events
```
import 'package:layers_flutter/layers_flutter.dart';

await Layers.init(LayersConfig(
  appId: 'YOUR_APP_ID',
  environment: 'production',
));

await Layers.track('purchase_success', properties: {'product_id': 'premium', 'revenue': 9.99});
```

## What to implement

1. **Initialize the SDK** at app startup (see the initialization code above).
2. **Track key events:**
   - `app_open` — when the app launches
   - `sign_up` — when a user creates an account
   - `login` — when a user logs in
   - `purchase_success` — when a purchase completes (include: product_id, revenue, currency, transaction_id)
   - `subscription_start` — when a subscription begins
   - `trial_start` — when a free trial starts
   - Any custom events relevant to my app
3. **Set user properties** after authentication:
   - User ID (via identify/setUserId)
   - Subscription tier, signup date, etc.
4. **Handle deep links** (if applicable):
   - Configure URL schemes and universal/app links
   - Forward deep link events to the SDK
5. **iOS only — App Tracking Transparency:**
   - Request ATT permission after onboarding
   - The SDK handles IDFA collection automatically after consent

## Event properties
Always include relevant properties with events:
- `revenue` and `currency` for purchase events
- `product_id` for product-related events
- `transaction_id` for purchase verification

## Important notes
- The SDK auto-tracks sessions and app lifecycle events
- Events are queued and batched automatically (flush every 30s or 20 events)
- The SDK handles attribution automatically — no additional setup needed

Please implement this SDK integration in my codebase, following the patterns and architecture already established in my project.
I need to integrate the Layers SDK into my Web app. Here are my credentials:

App ID: YOUR_APP_ID

## Installation

## 1. Install the package
```
npm install @layers/client
```

## 2. Initialize and track events
```
import { LayersClient } from '@layers/client';

const layers = new LayersClient({
  appId: 'YOUR_APP_ID',
  environment: 'production',
});
await layers.init();

await layers.track('purchase_success', { product_id: 'premium', revenue: 9.99 });
```

## What to implement

1. **Initialize the SDK** at app startup (see the initialization code above).
2. **Track key events:**
   - `app_open` — when the app / site loads
   - `sign_up` — when a user creates an account
   - `login` — when a user logs in
   - `purchase_success` — when a purchase completes (include: product_id, revenue, currency, transaction_id)
   - `subscription_start` — when a subscription begins
   - `trial_start` — when a free trial starts
   - Any custom events relevant to my app
3. **Set user properties** after authentication:
   - User ID (via identify/setUserId)
   - Subscription tier, signup date, etc.

## Event properties
Always include relevant properties with events:
- `revenue` and `currency` for purchase events
- `product_id` for product-related events
- `transaction_id` for purchase verification

## Important notes
- The SDK auto-tracks sessions and lifecycle events
- Events are queued and batched automatically (flush every 30s or 20 events)
- The SDK handles attribution automatically — no additional setup needed

Please implement this SDK integration in my codebase, following the patterns and architecture already established in my project.
I need to integrate the Layers SDK into my Node.js app. Here are my credentials:

App ID: YOUR_APP_ID

## Installation

## 1. Install the package
```
npm install @layers/node
```

## 2. Initialize and track events
```
import { LayersNode } from '@layers/node';

const layers = new LayersNode({
  appId: 'YOUR_APP_ID',
});
await layers.init();

// Node takes a per-call distinctId as the first argument
await layers.track('user-123', 'purchase_success', { product_id: 'premium', revenue: 9.99 });
```

## What to implement

1. **Initialize the SDK** at startup (see the initialization code above).
2. **Track key events** — Node is server-side, so pass the user's `distinctId` as the first argument to every `track` call:
   - `sign_up` — when a user creates an account
   - `login` — when a user logs in
   - `purchase_success` — when a purchase completes (include: product_id, revenue, currency, transaction_id)
   - `subscription_start` — when a subscription begins
   - `trial_start` — when a free trial starts
   - Any custom events relevant to my app
3. **Set user properties** after authentication:
   - Subscription tier, signup date, etc.

## Event properties
Always include relevant properties with events:
- `revenue` and `currency` for purchase events
- `product_id` for product-related events
- `transaction_id` for purchase verification

## Important notes
- Events are queued and batched automatically (flush every 30s or 20 events)
- Every `track` call takes the user's `distinctId` as its first argument

Please implement this SDK integration in my codebase, following the patterns and architecture already established in my project.

What the prompt covers

The prompt bundles everything the agent needs: the platform install steps, initialization, the recommended events with their properties, user identification, deep-link handling, and (on iOS) the App Tracking Transparency flow. For the reasoning behind each event and property, see Tracking events; for the attribution settings, see Attribution.

Prefer to wire it yourself? The Installation guide has the same steps as copyable, per-platform snippets. If your project is connected to GitHub, Layers can also open an install PR for you — see Overview → Automated install.

On this page