# Android web analytics installation - Docs

1.  1

    ## Install the dependency

    Required

    Add the PostHog Android SDK to your `build.gradle` dependencies:

    build.gradle

    PostHog AI

    ```kotlin
    dependencies {
        implementation("com.posthog:posthog-android:3.+")
    }
    ```

2.  2

    ## Configure PostHog

    Required

    Initialize PostHog in your Application class:

    SampleApp.kt

    PostHog AI

    ```kotlin
    class SampleApp : Application() {
        companion object {
            const val POSTHOG_PROJECT_TOKEN = "<ph_project_token>"
            const val POSTHOG_HOST = "https://us.i.posthog.com"
        }
        override fun onCreate() {
            super.onCreate()
            // Create a PostHog Config with the given project token and host
            val config = PostHogAndroidConfig(
                apiKey = POSTHOG_PROJECT_TOKEN,
                host = POSTHOG_HOST
            )
            // Setup PostHog with the given Context and Config
            PostHogAndroid.setup(this, config)
        }
    }
    ```

3.  3

    ## Track screen views

    Recommended

    Despite the name, the web analytics dashboard can be used to track screen views in mobile apps, too. Open your app and view some screens to generate some events.

    To automatically track screen views, configure PostHog to capture screen views:

    SampleApp.kt

    PostHog AI

    ```kotlin
    val config = PostHogAndroidConfig(
        apiKey = POSTHOG_PROJECT_TOKEN,
        host = POSTHOG_HOST
    ).apply {
        captureScreenViews = true
    }
    PostHogAndroid.setup(this, config)
    ```

4.  4

    ## Next steps

    Recommended

    After installing PostHog and ensuring [autocapture](/docs/data/autocapture.md) is enabled, head to your [web analytics dashboard](/docs/web-analytics/dashboard.md) to see your data. And then check out our [getting started](/docs/web-analytics/getting-started.md) guide.

    > **PostHog tip:** Web analytics works with [anonymous events](/docs/data/anonymous-vs-identified-events.md). This means if you are primarily using PostHog for web analytics, it can be significantly cheaper for you.

### Community questions

Ask a question

### Was this page useful?

HelpfulCould be better