> ## Documentation Index
> Fetch the complete documentation index at: https://www.macaly.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Google Analytics 4

> Add Google Analytics 4 to your Macaly project

Google Analytics 4 (GA4) shows you who visits your site, where they come from, and what they do. It's the standard tool for understanding website traffic.

The agent adds it in one step. You just need your measurement ID.

<Callout icon="user">
  Available on all plans
</Callout>

<Note>
  **Macaly has built-in analytics** too. If you just want to see page views and visitor counts, check out [Analytics](/en/features/analytics). It works out of the box with no setup. GA4 is for when you need deeper insights, audience segmentation, or integration with Google Ads.
</Note>

## Why use Google Analytics 4

* **Know exactly where your visitors come from.** See which channels bring traffic: organic search, social media, ads, or direct visits.
* **Measure what actually matters.** Define goals like signups, purchases, or form submissions and track how well your site converts.
* **Understand how people use your site.** See which pages they spend time on, where they drop off, and what devices they use.
* **Make your ads smarter.** If you run Google Ads, GA4 feeds conversion data back so you can optimize your spend.

## What you need

Before you start, make sure you have:

* A **Google Analytics account**. Create one for free at [analytics.google.com](https://analytics.google.com)
* Your **Measurement ID**. It looks like `G-XXXXXXXXXX` and you'll find it under **Admin → Data Streams → your stream**

<Accordion title="How to find your Measurement ID">
  1. Go to [analytics.google.com](https://analytics.google.com)
  2. Click **Admin** (gear icon) in the bottom left
  3. Under **Data collection and modification**, click **Data streams**
  4. Click your web stream (or create one if you haven't yet)
  5. Your **Measurement ID** is at the top. It starts with `G-`
</Accordion>

## Add GA4 to your project

Open the chat in your Macaly project and ask the agent:

```
Add Google Analytics 4 to my site. My measurement ID is G-XXXXXXXXXX.
```

The agent adds the GA4 tracking script to your project. Page views are tracked automatically from the moment it's live.

<Tip>
  Replace `G-XXXXXXXXXX` with your actual measurement ID.
</Tip>

## Verify it's working

<Steps>
  <Step title="Open GA4 Realtime report">
    Go to [analytics.google.com](https://analytics.google.com) and click **Reports → Realtime** in the left sidebar.
  </Step>

  <Step title="Visit your site">
    Open your published Macaly project in a browser tab.
  </Step>

  <Step title="Check for activity">
    Within a few seconds, you should see yourself as an active user in the Realtime report. If you navigate between pages, you'll see page view events appear.
  </Step>
</Steps>

<Info>
  Realtime data appears within seconds. Standard reports in GA4 can take 24 to 48 hours to fully populate.
</Info>

## Track more than page views

GA4 tracks page views automatically, but you can go further. Ask the agent to add tracking for specific actions:

| What to track        | Example prompt                                                                           |
| -------------------- | ---------------------------------------------------------------------------------------- |
| **Button clicks**    | *"Track when someone clicks the 'Get Started' button as a GA4 event called `cta_click`"* |
| **Form submissions** | *"Send a GA4 event called `form_submit` when the contact form is submitted"*             |
| **Purchases**        | *"Track purchases as GA4 `purchase` events with the order value"*                        |
| **Signups**          | *"Fire a GA4 `sign_up` event when a user creates an account"*                            |

The agent adds the tracking code and pushes the events to GA4 so they appear in your reports.

## GA4 vs Google Tag Manager

* **Use GA4 directly** if you only need analytics. It's simpler and you're done in one message.
* **Use [Google Tag Manager](/en/integrations/google-tag-manager)** if you plan to add multiple tools. GTM lets you manage GA4, Meta Pixel, and others from one dashboard.

<Info>
  **Cookie consent.** GA4 sets cookies to identify returning visitors. If your site has visitors from the EU, UK, or other regions with privacy laws, you are responsible for ensuring a cookie consent solution is in place before GA4 loads.
</Info>

## Good to know

* GA4 events can take **24 to 48 hours** to show up in standard reports. Use the **Realtime** report to verify right away
* **Built-in events** like page views, scrolls, outbound clicks, and file downloads are tracked automatically once GA4 is active
* You can connect GA4 to **Google Search Console** to see which search queries bring people to your site
* If you add GA4 through [Google Tag Manager](/en/integrations/google-tag-manager), you don't need to add it directly. That would double-count your data
