Integrating Amplitude analytics into a mobile application
Amplitude differs from Firebase Analytics in one fundamental way: data can be analyzed without writing SQL. Funnels, retention cohorts, user behavior paths — all through the console UI. For product teams analyzing data themselves, this changes decision-making speed.
SDK connection
iOS via Swift Package Manager — Amplitude-Swift package:
import AmplitudeSwift
// AppDelegate or @main App
let amplitude = Amplitude(configuration: Configuration(
apiKey: "YOUR_API_KEY",
defaultTracking: DefaultTrackingOptions(
sessions: true,
appLifecycles: true,
screenViews: false // manage manually
)
))
Singleton instance is better injected through a DI container rather than using Amplitude.instance() — this simplifies testing and SDK replacement in the future.
Android via Gradle:
implementation("com.amplitude:analytics-android:1.+")
val amplitude = Amplitude(
Configuration(
apiKey = "YOUR_API_KEY",
context = applicationContext,
defaultTracking = DefaultTrackingOptions(
sessions = true,
appLifecycles = true,
)
)
)
Events and properties
Amplitude works with the Event → Event Properties + User Properties model. Key difference from Firebase: event properties and user properties are clearly separated, and each event is automatically enriched with current user properties at the time of sending.
// Event with parameters
amplitude.track(
eventType: "Purchase Completed",
eventProperties: [
"product_id": "sku_12345",
"price": 990.0,
"currency": "RUB",
"payment_method": "card"
]
)
// User properties
amplitude.setUserId("user_\(userId)")
let identifyEvent = Identify()
identifyEvent.set(property: "plan", value: "premium")
identifyEvent.add(property: "total_purchases", value: 1)
amplitude.identify(identifyEvent: identifyEvent)
Identify.add() — atomic increment on the server. This is important with parallel sessions: set() will overwrite the last session's value, add() correctly sums.
Revenue tracking
Amplitude has a built-in Revenue object for monetization tracking — no need to manually add purchase events:
let revenue = Revenue()
revenue.productId = "premium_monthly"
revenue.price = 9.99
revenue.quantity = 1
revenue.revenueType = "subscription"
amplitude.revenue(revenue: revenue)
This automatically goes to the Revenue dashboard with LTV calculations by cohort.
Groups and account-level analytics
For B2B applications, Amplitude supports group analytics — events tied to an organization, not just a user:
amplitude.setGroup(groupType: "company", groupName: "Acme Corp")
amplitude.groupIdentify(
groupType: "company",
groupName: "Acme Corp",
identifyObj: Identify().set(property: "plan", value: "enterprise")
)
This is an Enterprise feature of Amplitude, but architecturally it's right to lay the groundwork for group support from the start.
Typical integration problems
Amplitude buffers events and sends them in batches (by default every 30 seconds or 30 events). If the app force-closes before a batch is sent, recent events may be lost. For critical events (purchase, activation), call amplitude.flush() explicitly.
Also: event names in Amplitude are case-sensitive. Purchase Completed and purchase completed — two different events in the dashboard. Need strict naming convention documented for the team.
What's included in the work
- SDK connection (iOS, Android or Flutter)
- Instance setup with correct tracking options
- Typed tracker layer with naming convention
- User Properties and Identify for segmentation
- Revenue tracking for monetization
- Event verification through Amplitude DebugMode
Timeline
Integration with events and user properties: 1–2 days. With Revenue tracking and groups: up to 3 days. Cost calculated individually.







