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.
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 →
Connections → Layers SDK → Get your 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@^3.3.0 @layers/react-native@^3.3.0 expo-tracking-transparency expo-linking
```
## 2. Add the plugin to app.json (under expo.plugins)
```
{
"expo": {
"plugins": [
["@layers/expo", {
"ios": { "attUsageDescription": "Helps show personalized content." }
}]
]
}
}
```
## 3. Initialize and track events
```
import { useEffect } from 'react';
import { LayersReactNative } from '@layers/expo';
const layers = new LayersReactNative({
appId: 'YOUR_APP_ID',
environment: 'production',
enableDebug: __DEV__,
});
// Call layers.init() once, from a useEffect in your root component.
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 `layers.setAppUserId('user-123')`)
- 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 ATT authorization
- Do not derive Layers consent from the ATT result; call `setConsent` only from the app's separate consent decision
## 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@^3.3.0 @react-native-community/netinfo @react-native-async-storage/async-storage
cd ios && pod install
```
## 2. Add the ATT usage description on iOS
Add this key to the app target's Info.plist before requesting ATT:
```
<key>NSUserTrackingUsageDescription</key>
<string>Explain why your app requests permission to use advertising identifiers.</string>
```
## 3. Initialize and track events
```
import { useEffect } from 'react';
import { LayersReactNative } from '@layers/react-native';
const layers = new LayersReactNative({
appId: 'YOUR_APP_ID',
environment: 'production',
enableDebug: __DEV__,
});
// Call layers.init() once, from a useEffect in your root component.
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 `layers.setAppUserId('user-123')`)
- 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 with `await layers.requestTrackingPermission()`
- The SDK handles IDFA collection automatically after ATT authorization
- Do not derive Layers consent from the ATT result; call `setConsent` only from the app's separate consent decision
## 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: "3.3.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 `Layers.identify(userId: "user-123")`)
- 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 ATT authorization
- Do not derive Layers consent from the ATT result; call `setConsent` only from the app's separate consent decision
## 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("com.layers.sdk:layers-android:3.3.0")
```
## 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 `LayersAndroid.identify("user-123")`)
- 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: ^3.3.0
```
## 2. Initialize and track events
```
import 'package:layers_flutter/layers_flutter.dart';
await Layers.init(LayersConfig(
appId: 'YOUR_APP_ID',
environment: LayersEnvironment.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 `Layers.identify('user-123')`)
- 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 ATT authorization
- Do not derive Layers consent from the ATT result; call `setConsent` only from the app's separate consent decision
## 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 Unity game. Here are my credentials:
App ID: YOUR_APP_ID
## Installation
## 1. Add the UPM package to Packages/manifest.json
```
{
"dependencies": {
"com.layers.analytics": "https://github.com/layers/layers-sdk-unity.git#v3.3.0"
}
}
```
## 2. Initialize and track events
```
using System.Collections.Generic;
using Layers.Unity;
using UnityEngine;
public class LayersBootstrap : MonoBehaviour
{
void Awake()
{
LayersSDK.Initialize(new LayersConfig
{
AppId = "YOUR_APP_ID",
Environment = LayersEnvironment.Production,
});
}
}
LayersSDK.Track("purchase_success", new Dictionary<string, object>
{
["product_id"] = "premium",
["revenue"] = 9.99,
});
```
## What to implement
1. **Initialize the SDK** in an `Awake()` on a bootstrap MonoBehaviour in the first scene, before any other Layers call.
2. **Track key events** with `LayersSDK.Track(name, properties)`:
- `app_open` — auto-tracked on init, leave it on
- `sign_up` — when a player creates an account
- `login` — when a player 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 game events (level start/complete, tutorial steps, economy sinks)
3. **Use the typed helpers** where they fit: `StandardEvents` for the canonical event names and property bags, and `Commerce.TrackPurchase` / `Commerce.TrackSubscription` for revenue.
4. **Identify the player** after authentication with `LayersSDK.Identify("player-id")`, then `LayersSDK.SetUserProperties(...)` for tier, level, and so on. Call `LayersSDK.Reset()` on sign-out.
5. **Screen views:** call `LayersSDK.Screen("MainMenu")` on scene or major UI changes.
6. **Deep links** are auto-tracked. Subscribe to `DeepLinksModule.OnDeepLinkReceived` if the game needs to route on them.
7. **Build settings:** create a settings asset via **Assets → Create → Layers → Settings** and fill in the ATT usage description, URL schemes, and associated domains. The post-build processors handle Info.plist, framework linking, and Android intent filters.
8. **iOS only — App Tracking Transparency:** call `LayersSDK.RequestTrackingPermission(status => { ... })` after onboarding. Do not map that status onto `LayersSDK.SetConsent`; call `SetConsent` separately only from the game's own consent decision.
## 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
- Targets iOS and Android on Unity 2021.3 LTS or later. WebGL is not supported.
- The SDK auto-tracks sessions and app lifecycle events
- Events are queued and batched automatically (flush every 30s or 20 events)
- Set `EnableDebug = true` in LayersConfig during development, and turn it off for release builds
- The SDK handles attribution automatically (Install Referrer on Android, SKAdNetwork and ATT on iOS)
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();
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 `layers.setUserId('user-123')`)
- 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',
environment: 'production',
});
await layers.init();
// Node takes a per-call distinctId as the first argument
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.
Installation
Install and initialize the Layers SDK on Expo, React Native, iOS, Android, Flutter, Unity, Web, or Node — install the package, initialize with your App ID, and send your first event.
Tracking events
The events worth tracking with the Layers SDK, the properties to send with them, how to identify users, and how the SDK batches and flushes events.