Skip to main content

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):

PropertyDescriptionExample
app_nameApplication display name"B2MetricAnalytics"
app_bundle_idBundle identifier"com.b2metric.analytics"
app_versionApp version string"1.0.0"
country_codeDevice region code"TR"
device_idUUID generated on first install"a3f5b8c1-..."
device_modelDevice model name"iPhone 15 Pro"
device_tokenAPNs push token"abc123..."
languageDevice locale"tr_TR"
os_versioniOS version"17.2"
platformAlways "iOS""iOS"
screen_resolutionDisplay resolution"1179x2556"
timezoneIANA 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