Setting Up Analytics for Your App
Analytics setup is a short plan, ten or so well-named events, one place to store them, and a test pass before launch. Here is the whole job, step by step.

Key takeaways
- Write a tracking plan before you add any code: ten to fifteen events, named object then action, each with a short list of properties.
- Pick one place for events. A simple events table in your own database is enough for a first launch; a dedicated analytics tool earns its place once you need funnels and cohorts every week.
- Ask for consent where the law requires it, never send personal data as event properties, and test every event by hand before launch day.
To set up analytics for your app, write a short tracking plan (the ten to fifteen events that describe your core flow), choose one place to store them (an events table in your own database or a dedicated analytics tool), add a consent step where your users’ laws require one, then trigger every event yourself and confirm it lands before launch. That is an afternoon of work, and it is far cheaper to do before launch than to reconstruct afterward, because events you never recorded are gone for good.
This guide is about the plumbing. Which numbers deserve your attention once data flows is a separate question, covered in the app metrics that matter early.
Step 1: write the tracking plan
A tracking plan is a table with four columns: event name, when it fires, its properties, and the question it answers. If an event does not answer a question you will actually ask, cut it. Most first launches need fewer events than founders expect, and a small, clean plan beats a firehose of auto-captured clicks nobody can interpret.
Naming rules that survive a year
- Object, then action, past tense: `project_created`, `invite_sent`, `checkout_started`, `plan_upgraded`. Sorting alphabetically then groups everything about one object.
- One style, forever: lowercase with underscores. `Signed Up`, `signup` and `user_signed_up` in the same table make every query a guessing game.
- Name what happened, not the button: `booking_confirmed`, not `blue_button_clicked`. Buttons move during redesigns; the meaning stays.
- Properties carry the detail: one `item_added` event with a `source` property (search, recommendation, reorder) beats three separate events.
A starter plan for a typical app
Adapt this to your own core flow. For a booking app, the “core action” is a confirmed booking; for a habit tracker, a logged check-in; for a game, a finished run.
- 01`account_created` with `method` (email, Google, anonymous) and `referrer`.
- 02`onboarding_step_completed` with `step` and `step_index`, so you can see exactly where new people stall.
- 03`core_action_completed` (renamed to your real action) with the one or two properties that matter, such as `duration_seconds` or `item_count`.
- 04`invite_sent` and `invite_accepted`, if sharing is part of the product.
- 05`paywall_viewed`, `checkout_started`, `plan_upgraded`, `plan_canceled` with `plan` and `price_id`.
- 06`error_shown` with `screen` and a short `code`, so silent failures show up as numbers instead of anecdotes.
- 07`feedback_submitted` with `score`, if you ask for ratings in the app.
Step 2: choose where events live
There are two reasonable homes for events, and you can start with one and add the other later.
Option A: an events table in your own database
One table, a handful of columns: `id`, `user_id` (nullable for visitors), `name`, `properties` (JSON), `created_at`. Every event your app fires becomes a row. The advantages are real for an early product: no extra vendor, no extra cookie banner purely for a third-party script, data you own and can join against your actual users and orders, and queries in plain SQL.
On Startbase, this lives in Startbase Cloud, the managed backend you attach to a project. The table browser shows events as they arrive, and the SQL editor answers questions like “how many people who created an account last week completed the core action?” Startbase does not ship a product analytics dashboard of its own: the publish panel’s Traffic row shows visits over the last 30 days and the Users section has a 30-day signup chart, and everything beyond that is your own table and your own queries. A brief that sets it up:
Add first-party analytics. Create an events table with id, user_id (nullable), anonymous_id, name, properties as JSON and created_at, with row-level security so a signed-in user can only insert their own events and nobody can read events from the app. Add a small track(name, properties) helper that never throws and never blocks the UI. Fire these events: account_created, onboarding_step_completed, booking_confirmed, invite_sent, paywall_viewed, checkout_started, plan_upgraded, error_shown. Never put emails, names or free text in properties. Then show me a SQL query for weekly signups and how many of them confirmed a booking within 7 days.
Option B: a dedicated analytics tool
Product analytics services give you funnels, retention charts, cohorts and session replays without writing SQL. They are worth adding when you look at funnels every week and the SQL is slowing you down, or when a non-technical teammate needs to explore data alone. The costs: another script on your pages, another processor in your privacy policy, a pricing tier that grows with events, and data that lives on someone else’s servers. If you add one, keep the same event names from your tracking plan, so moving or mirroring later is a find-and-replace, not a rebuild.
For marketing pages, a lightweight, cookie-free page analytics tool is often enough to see visits and referrers. Product events (what signed-in people do inside the app) are the part worth owning.
Step 3: connect visitors to accounts
The most common analytics bug is a broken identity chain: someone browses as a visitor, signs up, and appears in your data as two unrelated people. Fix it with two IDs:
- anonymous_id: a random ID stored in the browser on first visit, attached to every event before sign-up.
- user_id: your real account ID, attached from the moment someone signs in. On sign-up, record both together once, so later queries can stitch the visitor history to the account.
If your app allows anonymous sign-in (letting people try it before creating an account), the anonymous user already has an ID in your auth system; use it, and link it when they upgrade to a full account.
Step 4: consent and privacy
Rules vary by country and this is not legal advice, but the practical baseline for a small app is clear:
- Collect the minimum. Event names and a few properties answer almost every product question. Emails, names, addresses, message contents and anything typed into a text field do not belong in events.
- Know when you need consent. In the EU and UK, non-essential cookies and similar trackers generally need opt-in consent first. First-party events tied to running the service you provide are a different case from third-party advertising trackers, so understand which you use.
- Respect the answer. If someone declines, the third-party script does not load. Wire the banner to actually gate the script; a banner that changes nothing is worse than none.
- Disclose it. List what you collect and which tools process it in your privacy policy. Our guide to writing a privacy policy for your app covers what to include.
- Set a retention period. Raw events older than a year or two rarely answer new questions. A scheduled job that deletes old rows keeps the table small and your privacy promise true.
Step 5: test every event before launch
Untested analytics are worse than none, because they look trustworthy. Before launch, run this pass yourself, in a fresh browser profile:
- 01Open the tracking plan next to the app.
- 02Walk the core flow as a brand new visitor: land, sign up, finish onboarding, do the core action, hit the paywall, invite someone.
- 03After each step, check the events table (or the tool’s live view) for exactly one new row with the right name and properties.
- 04Look for duplicates: a React screen that renders twice can fire an event twice. Fire “on success” events only after the server confirms.
- 05Check the stitching: your pre-signup events should connect to the new account.
- 06Repeat on a phone. Mobile browsers block more scripts, and some events only misfire there.
- 07Decline consent once and confirm nothing third-party fires.
Then exclude yourself. Tag your own account and your team’s accounts (an `is_internal` flag on the user works) and filter them from every query. In the first weeks, your own testing can easily be a large share of all activity.
Keeping it healthy after launch
- A weekly glance at volumes. If `account_created` suddenly drops to zero while the Users chart shows signups, the event broke, not the business.
- New feature, new events, same PR. Add events in the same change as the feature, named from the plan.
- Version, do not rename. If an event’s meaning changes, create a new name and retire the old one, rather than silently changing what historic rows mean.
- Pair numbers with people. Events tell you where people drop off; only conversations tell you why. Our guide to collecting user feedback covers the other half.
With the plumbing in place, you are ready for the questions that matter: whether people reach the core action, whether they come back, and whether they pay.
Frequently asked questions
Do I need Google Analytics for a new app?
No. Page analytics show visits and referrers, which matter for marketing pages, but they say little about what signed-in people do inside the app. A small events table or a product analytics tool answers those questions better. Many early apps use a light page counter plus their own events.
How many events should I track at launch?
Ten to fifteen is plenty for most first versions: sign-up, onboarding steps, the core action, sharing, paywall and payment events, and errors. Add more only when a specific question needs them.
Is it legal to track users in my app?
Usually yes, with conditions that depend on where your users live. Collect the minimum, avoid personal data in events, disclose what you track in your privacy policy, and get opt-in consent for non-essential trackers where the law requires it. For anything sensitive, ask a lawyer.
Should analytics run in my app preview?
Fire events in previews if it helps you test, but mark them (an environment property such as preview or live) and filter them out of every real report, along with your own accounts.

