Guides / Prompting and shipping

How to Add Analytics to Your App: GA4, Privacy-First Tools and Product Analytics

How to add analytics to your website or app: Google Analytics 4 vs privacy-first vs product analytics, what to track, cookie consent, and prompts to use.

Mythex Team · 2026-09-29 · 5 min read

To add analytics to your app, pick one tool, add its small script (or ask your app builder to add it) so it loads on every page, confirm page views show up in the tool's real-time view, then track a handful of events that matter — sign-ups, purchases, key actions. Use Google Analytics 4 if you want a free, full-featured tool and can handle cookie consent; a privacy-first tool like Plausible if you want simple stats without cookies; and a product analytics tool like PostHog if you need to see what logged-in users do inside the app. Vendor details below are from each vendor's own site as of September 2026.

Decide what you want to learn

Analytics is only useful if it answers a question. Write down three to five before you install anything:

  • Where do visitors come from (search, social, a newsletter, an ad)?
  • Which pages do people land on, and where do they leave?
  • How many visitors sign up, start a trial, or buy?
  • Which features do active users actually use?
  • Do people come back after their first week?

The first two are web analytics. The last two are product analytics. The middle one is a conversion and needs you to track an event.

Your options

TypeExamplesGood forTrade-offs
Full web analyticsGoogle Analytics 4Traffic sources, campaigns, ads, free at small scaleComplex interface; uses cookies, so consent is often needed
Privacy-first web analyticsPlausible and similarSimple dashboards, fewer consent headachesPaid, fewer advanced reports
Product analyticsPostHog and similarFunnels, retention, feature usage, session replayMore setup; you should identify users carefully
Your own events tableA table in your app's databaseCounting a few key actions exactlyYou build the reports yourself

Google Analytics 4

Google's help centre says you can connect a website to Google Analytics free of charge. Setup is: create an account, create a property, add a web data stream, then add the Google tag with your measurement ID (it starts with G-). Google notes data can take up to 30 minutes to start appearing; the Realtime report is the quickest way to check it works.

GA4's documentation says its tags use first-party cookies (including _ga) to tell users and sessions apart. That matters for consent rules — see below.

Plausible

Plausible says it uses no cookies or other persistent identifiers and that no cookie banner is required for it. Its site describes the script as about 2.5 KB gzipped, and its code is open source, with a self-hosted option. It has no free plan: as of September 2026 there is a 30-day free trial with no card required, and the Starter plan is listed at $9/month for up to 10,000 monthly page views. See Plausible's site for current pricing.

PostHog

PostHog focuses on product analytics — funnels, retention and session replay — rather than just page views. Its pricing page lists a monthly free allowance of 1 million product analytics events and 5,000 session replay recordings, with no credit card required, as of September 2026. See PostHog pricing.

Your own events table

For a few business-critical numbers (sign-ups per day, orders per week), writing a row to your own database when the event happens is exact, private and free of third-party scripts. It's a good complement to any tool above, not a replacement for traffic reports.

Cookie consent and privacy

Rules on analytics cookies vary by country. In the EU and UK, cookies that aren't strictly necessary generally need the visitor's consent before they're set, and analytics usually falls in that group. This isn't legal advice; check the rules for where your visitors are, or ask an adviser.

Practically:

  • With a cookie-based tool, load it only after consent, and make "reject" as easy as "accept".
  • With a cookie-free tool, you may avoid the banner for analytics, but you still need a privacy policy saying what you collect.
  • Never send personal data (emails, names, full addresses) to analytics in event names, page URLs or properties.

Example prompts

Adding a web analytics tool:

Add Google Analytics 4 with measurement ID G-XXXXXXX. Load the tag on every page, but only after the visitor accepts analytics cookies in a simple consent banner (Accept / Reject, choice remembered). Make sure page views are recorded when navigating between pages in this single-page app.

Tracking conversions:

Send an analytics event called sign_up when a user finishes registration, and purchase with the order value when checkout succeeds. Don't include email addresses or names in any event.

Your own metrics:

Create an events table (name, user ID, created-at, small JSON details). Record sign_up, project_created and invite_sent from the server. Add an admin page with daily counts for the last 30 days.

Step by step

  1. Write your questions (above) and pick one tool that answers them. Don't install three.
  2. Create the account and property in the tool and copy the site ID or measurement ID. These IDs are public by design; they're not secrets.
  3. Add the script to every page, respecting consent if the tool uses cookies.
  4. Check page views in the tool's real-time view while you click around your published site. For single-page apps, confirm each page change is counted — GA4's enhanced measurement, for example, can record page views on browser history changes.
  5. Exclude yourself where the tool allows, so your own testing doesn't skew numbers.
  6. Add 3–5 key events: sign-up, purchase, the one action that means someone got value.
  7. Tag your links in newsletters and posts with UTM parameters (?utm_source=newsletter) so you know which channel worked.
  8. Look weekly. Set a reminder. Analytics nobody reads is wasted setup.

Common mistakes

  • Tracking only in preview. Analytics should run on the published site; many tools ignore or mis-attribute preview domains.
  • Double counting. The script added twice (in the layout and a page) inflates everything.
  • Missing page changes in single-page apps. You see one page view per visit and conclude nobody browses.
  • Personal data in URLs or events. An email in a query string ends up in your analytics reports.
  • Loading cookie-based tags before consent where consent is required.
  • Tracking everything. Dozens of events nobody looks at make the useful ones harder to find.
  • Judging from a week of tiny numbers. With low traffic, day-to-day swings are noise.

Checklist

  • You've written the questions analytics should answer
  • One tool installed on every page of the published site
  • Page views appear in real time, including in-app page changes
  • Consent handled where the tool uses cookies
  • 3–5 key events tracked, with no personal data
  • Your own visits excluded where possible
  • Privacy policy mentions analytics
  • A weekly time to review the numbers

Adding analytics in Mythex

Mythex doesn't include a built-in analytics dashboard for your app's visitors; analytics is bring-your-own, as the docs note for landing pages. Paste the tool's measurement or site ID into chat with a prompt like the ones above, or for server-side keys (some product analytics APIs), store them as project secrets and follow Integrate any API. Test on your published URL, then publish again after changes.

Once numbers come in, use them: see how to launch an app and get first users, how to build a landing page that converts and SEO for AI-built websites.

Questions

Is Google Analytics free?

Yes. Google's own help pages say you can connect a website or app to Google Analytics free of charge. You create an account, a property and a web data stream, then add the Google tag with your measurement ID, which starts with G-.

Do I need a cookie banner for analytics?

It depends on the tool and where your visitors are. Google Analytics 4 sets first-party cookies, which in places like the EU and UK generally means asking for consent first. Some privacy-first tools say they use no cookies. Check the rules that apply to you, or ask an adviser.

Why does my single-page app only record one page view?

Single-page apps change pages without a full reload. The analytics tool has to listen for browser history changes; GA4's enhanced measurement can do this, and other tools have similar settings. Check that page views appear as you click between pages.

What is the difference between web analytics and product analytics?

Web analytics answers where visitors come from and which pages they view. Product analytics tracks what logged-in users do inside the app — which features they use, where they drop off, whether they come back.

Keep reading

  • How to Add a Blog to Your Website: Options, SEO and Setup — How to add a blog to your website: Markdown files vs a built-in editor vs a CMS, subfolder vs subdomain, SEO basics, and prompts to build it with AI.
  • How to Add a Contact Form to Your Website (That Actually Reaches You) — How to add a contact form that works: save messages, get email alerts, stop spam, and avoid the mistakes that silently lose enquiries. Prompts included.
  • How to Add a Database to Your App (Without Losing Data Later) — How to add a database to an app you built: when you need one, Postgres vs hosted options, designing tables, prompts to use, and mistakes that lose data.
  • How to Add AI Features to Your App — Add summaries, chat, data extraction and classification to your app with an LLM API — keeping keys safe, costs under control and output trustworthy.
  • How to Add Cookie Consent to Your Website — Add a cookie banner that actually blocks scripts until people agree: what needs consent, CMP vs custom, Google consent mode and a checklist. Not legal advice.
  • How to Add Dark Mode to Your Website or App (Without the Flash) — How to add dark mode: follow the system setting or add a toggle, use colour tokens, avoid the white flash on load, and check contrast. Prompts included.

Start building free · Templates · Docs