Automatic Event Tracking
The SDK automatically tracks key lifecycle and screen view events without any code from you. These events help you understand user behavior and app usage patterns.
Automatically Tracked Events
B2Metric tracks the following events automatically when you initialize the SDK:
first_open
Tracks when a user opens your app for the very first time after installation. This event is logged only once per device and helps you measure new user acquisition.
When it fires:
- First app launch after installation
- Only fires once per device lifetime
user_properties
Logged immediately after startup with device and app information. Properties tracked (sent with every event):
| Property | Description | Example |
|---|---|---|
app_name | Application display name | "B2MetricAnalytics" |
app_bundle_id | Bundle identifier | "com.b2metric.analytics" |
app_version | App version string | "1.0.0" |
country_code | Device region code | "TR" |
device_id | UUID generated on first install | "a3f5b8c1-..." |
device_model | Device model name | "iPhone 15 Pro" |
device_token | APNs push token | "abc123..." |
language | Device locale | "tr_TR" |
os_version | iOS version | "17.2" |
platform | Always "iOS" | "iOS" |
screen_resolution | Display resolution | "1179x2556" |
timezone | IANA timezone string | "Europe/Istanbul" |
session_start
Tracks when a user starts a new session. A new session begins when the app comes to the foreground.
When it fires:
- App is opened from closed state
- App returns to foreground after being in background
session_end
Tracks when a user's session ends. This happens when the app moves to the background.
When it fires:
- App moves to background
- Next time app comes to foreground
How Sessions Work
The SDK uses iOS notifications (UIApplication.didBecomeActiveNotification and UIApplication.didEnterBackgroundNotification) to automatically detect when your app moves between foreground and background.
User opens app → session_start fires
User interacts for 10m → Session continues
User backgrounds app → session_end fires
User returns to app → new session_start fires