--- title: How to set up analytics in Android date: 2024-03-01 author: - lior-neu-ner tags: - product analytics - web analytics --- import { ProductScreenshot } from 'components/ProductScreenshot' export const EventsInPostHogLight = "https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/tutorials/android-analytics/events-light.png" export const EventsInPostHogDark = "https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/tutorials/android-analytics/events-dark.png" export const IdentifyLight = "https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/tutorials/android-analytics/identify-light.png" export const IdentifyDark = "https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/tutorials/android-analytics/identify-dark.png" export const InsightLight = "https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/tutorials/android-analytics/create-insights-light.png" export const InsightsDark = "https://res.cloudinary.com/dmukukwp6/image/upload/posthog.com/contents/images/tutorials/android-analytics/create-insights-dark.png" [Product analytics](/product-analytics) enable you to gather and analyze data about how users interact with your Android app. To show you how to set up analytics, in this tutorial we create a basic Android app with Kotlin, add PostHog, and use it to [capture events](/docs/product-analytics/capture-events) and [create insights](/docs/product-analytics/insights). ## 1. Create a new Android app Our app will have two screens: - a `login` screen with a form to enter in your name, email, and company name. - a `home` screen with submit button, toggle, and logout button. The first step is to create a new app. Open [Android Studio](https://developer.android.com/studio) and create a new project. Select `Empty Activity`, name your project `Android-Analytics`, and use the defaults for everything else. Then, create a new activity `HomeActivity` by clicking `File > New > Activity > Empty Views Activity`. Replace the code in the new activity with the following: ```kotlin file=HomeActivity.kt package com.example.android_analytics import android.content.Context import android.content.Intent import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import android.widget.Button import android.widget.Toast import android.widget.ToggleButton class HomeActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_home) val submitButton = findViewById