google analytics with astro

Google Analytics with Astro

Most sites have GA4 installed. Fewer have numbers anyone trusts. I clean up the container, define the events that matter and make sure consent and performance are handled deliberately.

Google Analytics at a glance

What I do
GA4 and Tag Manager set up on an Astro site with clean events, consent behavior and performance-conscious loading.
Typical setup
Adds 2–4 days
How it is bought
Part of a migration scope, or a Continuous development request once the site is yours

How I set up Google Analytics

The setup starts with measurement decisions, not scripts. What counts as a conversion? Which events will someone actually read six months from now? Which tags are still needed and which are leftovers from old campaigns?

I usually prefer Tag Manager once a site needs more than basic measurement, because it keeps marketing tags in one auditable place and avoids republishing the site for every pixel change. That only works if the container is disciplined. A messy container is just hidden technical debt.

Consent is part of the measurement architecture, not an afterthought. Google Consent Mode needs the right default state before measurement begins and an update when the visitor makes a choice. I check that behavior in Tag Assistant rather than assuming it: that tags fire when they should, stay quiet when they should and do not block the page from loading well.

The deliverable is not an installed tag. It is a measurement setup where the browser, the consent layer and the CRM tell the same story.

How the handoff works

  1. 01

    Consent

    Permission state is known

  2. 02

    Tag

    GA4 loads correctly

  3. 03

    Pageview

    Context and campaign arrive

  4. 04

    Conversion

    The right events fire

    Key handoff

  5. 05

    Verify

    Conversions checked against CRM records

Why this is the key handoff

A tag that fires is not a number you can use. A pageview in GA4 only proves the tag fired. I check that consent, attribution and conversions survive the whole journey and reconcile with what happened downstream.

What gets connected

  • GA4 directly, through Tag Manager, or through the agreed tag architecture

  • A short list of conversion and engagement events

  • Form submissions, outbound clicks and campaign attribution

  • Consent Mode behavior connected to the banner

  • Redirect and UTM handling across the site

What to watch out for

  1. 01

    A checkout or booking on another domain can break attribution

    Without cross-domain measurement and the referral exclusions to go with it, a visitor who leaves for a payment processor or a scheduler comes back looking like new referral traffic. The conversion survives and the campaign that produced it is obscured, which is a configuration problem rather than something inevitable.

  2. 02

    An inline form success is not a destination page

    For a form that swaps in a success state without navigating, so a conversion configured as a destination never fires. It is tracked as an event on the successful submission instead, and the difference is invisible until the report is empty.

  3. 03

    The container is where third-party scripts accumulate

    GA4 itself is small. Tags added through a container bypass the usual development workflow, so old campaign pixels, a second analytics tool and heavy vendor scripts outlive anybody's memory of why they were added. Tag Manager changes need the same ownership and review as other site changes.

Next step

Let me plan your next step.

Send your site

I can scope a migration. Send a brief and I will reply by email with next steps.