# Mobile app install and lifecycle events
> Automatically track mobile app install, foreground, and background events with lifecycle entities for app usage analysis.
> Source: https://docs.snowplow.io/docs/events/ootb-data/mobile-lifecycle-events/
> Documentation index: https://docs.snowplow.io/llms.txt

Mobile lifecycle events track key moments in your app's usage: when a user installs the app, opens it, or switches away. These events help you understand user engagement patterns, measure retention, and analyze session behavior.

We recommend using the [Base mobile tracking plan template](/docs/event-studio/tracking-plans/templates/#base-mobile) for mobile tracking. It includes install and lifecycle events.

## Install events

The mobile trackers can automatically track an install event when the app is first opened after installation.

This table shows the support for mobile application install tracking across the main client-side [Snowplow tracker SDKs](/docs/sources/). Depending on your tracker and version, install autotracking may be enabled by default.

| Tracker                                                                                   | Supported | Since version | Auto-tracking | Notes                           |
| ----------------------------------------------------------------------------------------- | --------- | ------------- | ------------- | ------------------------------- |
| Web                                                                                       | ❌         |               |               |                                 |
| [iOS](/docs/sources/mobile-trackers/tracking-events/installation-tracking/)               | ✅         | 1.1.0         | ✅             |                                 |
| [Android](/docs/sources/mobile-trackers/tracking-events/installation-tracking/)           | ✅         | 1.1.0         | ✅             |                                 |
| [React Native](/docs/sources/react-native-tracker/tracking-events/installation-tracking/) | ✅         | 0.1.0         | ✅             | Only relevant for mobile events |
| [Flutter](/docs/sources/flutter-tracker/initialization-and-configuration/)                | ✅         | 0.11.1        | ✅             | Disabled by default             |
| Roku                                                                                      | ❌         |               |               |                                 |
| Google Tag Manager                                                                        | ❌         |               |               |                                 |

> **Note: No uninstall events**
>
> It's not possible to track when an app is uninstalled, since the mobile platforms don't provide a callback where such an event could be tracked.

This event has no properties since the relevant data is the timestamp, which is captured in the standard event fields.

### `application_install`

**Type:** Event

Schema for an event where a mobile application is installed.

**Properties:**

**Example warehouse query (Snowflake):**

```sql
select
unstruct_event_com_snowplowanalytics_mobile_application_install_1 application_install_1
from
atomic.events
where
events.collector_tstamp > getdate() - interval '1 hour'
and events.event = 'unstruct'
and events.event_name = 'application_install'
and events.event_vendor = 'com.snowplowanalytics.mobile'
```

### Android referrer details entity

On Android only, the Android tracker can attach an extra [entity with install referrer information](/docs/sources/mobile-trackers/tracking-events/installation-tracking/#android-only-tracking-referrer-information-from-the-google-play-referrer-library) to the install event. It makes use of the [Google Play Install Referrer library](https://developer.android.com/google/play/installreferrer) to retrieve the referrer information.

This entity is available from Android tracker version 5.2.0 onwards.

### `referrer_details`

**Type:** Event

Represents an install referrer details for Android apps installed from the Play Store (see https\://developer.android.com/reference/com/android/installreferrer/api/ReferrerDetails)

**Properties:**

| Property                           | Description                                                                                                    |
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `installReferrer` _string_         | _Optional._ The referrer URL of the installed package                                                          |
| `referrerClickTimestamp` _string_  | _Optional._ The timestamp when referrer click happens                                                          |
| `installBeginTimestamp` _string_   | _Optional._ The timestamp when installation begins                                                             |
| `googlePlayInstantParam` _boolean_ | _Required._ Boolean indicating if the user has interacted with the app's instant experience in the past 7 days |

**Example warehouse query (Snowflake):**

```sql
select
unstruct_event_com_android_installreferrer_api_referrer_details_1 referrer_details_1
from
atomic.events
where
events.collector_tstamp > getdate() - interval '1 hour'
and events.event = 'unstruct'
and events.event_name = 'referrer_details'
and events.event_vendor = 'com.android.installreferrer.api'
```

## Foreground and background

Foreground and background events capture when the user switches to or away from your app. A foreground event fires when the app becomes visible on screen, while a background event fires when the user switches to another app or returns to the home screen.

The mobile trackers can track these events automatically. They also attach a lifecycle entity to all events, indicating whether the app was visible when each event occurred.

This table shows the support for mobile lifecycle event tracking across the main client-side [Snowplow tracker SDKs](/docs/sources/). The server-side trackers don't include lifecycle event tracking. Depending on your tracker and version, lifecycle autotracking may be enabled by default.

| Tracker                                                                                                | Supported | Since version | Auto-tracking | Notes                           |
| ------------------------------------------------------------------------------------------------------ | --------- | ------------- | ------------- | ------------------------------- |
| Web                                                                                                    | ❌         |               |               |                                 |
| [iOS](/docs/sources/mobile-trackers/tracking-events/#tracking-deep-links)                              | ✅         | 3.0.0         | ✅             |                                 |
| [Android](/docs/sources/mobile-trackers/tracking-events/#tracking-deep-links)                          | ✅         | 3.0.0         | ✅             |                                 |
| [React Native](/docs/sources/react-native-tracker/tracking-events/#tracking-deep-link-received-events) | ✅         | 0.1.0         | ✅             | Only relevant for mobile events |
| [Flutter](/docs/sources/flutter-tracker/initialization-and-configuration/)                             | ✅         | 0.5.0         | ✅             | Only relevant for mobile events |
| Roku                                                                                                   | ❌         |               |               |                                 |
| Google Tag Manager                                                                                     | ❌         |               |               |                                 |

### Foreground event

The foreground event is tracked each time the app becomes visible on the screen. The `foregroundIndex` property counts how many times the app has been foregrounded since installation.

### `application_foreground`

**Type:** Event

Schema for an application foreground event

**Properties:**

| Property                    | Description |
| --------------------------- | ----------- |
| `foregroundIndex` _integer_ | _Optional._ |

**Example warehouse query (Snowflake):**

```sql
select
unstruct_event_com_snowplowanalytics_snowplow_application_foreground_1 application_foreground_1
from
atomic.events
where
events.collector_tstamp > getdate() - interval '1 hour'
and events.event = 'unstruct'
and events.event_name = 'application_foreground'
and events.event_vendor = 'com.snowplowanalytics.snowplow'
```

### Background event

The background event is tracked when the app is no longer visible, such as when the user switches to another app or returns to the home screen. The `backgroundIndex` property counts how many times the app has been backgrounded since installation.

### `application_background`

**Type:** Event

Schema for an application background event

**Properties:**

| Property                    | Description |
| --------------------------- | ----------- |
| `backgroundIndex` _integer_ | _Optional._ |

**Example warehouse query (Snowflake):**

```sql
select
unstruct_event_com_snowplowanalytics_snowplow_application_background_1 application_background_1
from
atomic.events
where
events.collector_tstamp > getdate() - interval '1 hour'
and events.event = 'unstruct'
and events.event_name = 'application_background'
and events.event_vendor = 'com.snowplowanalytics.snowplow'
```

### Lifecycle entity

When lifecycle autotracking is enabled, this entity is automatically attached to all events. It indicates whether the app was in the foreground or background when the event occurred.

### `application_lifecycle`

**Type:** Schema

Entity that indicates the visibility state of the app (foreground, background)

**Properties:**

| Property              | Description                                                                                                                                                              |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `isVisible` _boolean_ | _Required._ Indicates if the app is in foreground state (true) or background state (false)                                                                               |
| `index` _integer_     | _Optional._ Represents the foreground index or background index (tracked with com.snowplowanalytics.snowplow application\_foreground and application\_background events. |
