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

# Set up web tracking

> Add allGood's tracking tag to any site you run, so page views and visitor activity land in allGood.

Web tracking is a single script tag you paste into the pages you want tracked. Once it's live, allGood records page views on those pages and can receive any custom events your team chooses to send.

<Tip>
  Installing this for a marketer, not building against it? See [Set up Web Tracking on your site](/mk/settings/web-edge/tracking-setup) for the settings-only walkthrough.
</Tip>

There's no site to register first. You issue one tracking key for your account, paste the tag wherever you like, and the [allowed origins list](/mk/developer/web-edge/allowed-origins) decides which of those sites is actually permitted to send anything.

## Why this matters

Without the tag, allGood can't see what happens on your website. You can still send campaigns and publish landing pages, but you won't know who read the pricing page twice before filling in a form, or who came back a week later. The tag is what connects your marketing to what visitors actually do.

## Before you start

* A domain must be **connected and active** — the tag is served from your own allGood subdomain, so without one there's no address to load it from. See [Connect your subdomain](/mk/developer/web-edge/connect-a-domain).
* The website's origin must be on your [allowed origins list](/mk/developer/web-edge/allowed-origins), or nothing it sends is accepted.
* You need a way to edit the `<head>` of your pages, either directly or through a tag manager.

<Frame caption="The Web Tracking settings page, showing the generated tag, the account's tracking key, and the two switches that control what the tag sends.">
  <img src="https://mintcdn.com/allgoodtechnologyinc/bSgN7e8oktmf793O/images/mk/web-edge/setup-web-tracking.png?fit=max&auto=format&n=bSgN7e8oktmf793O&q=85&s=333e460b34218c3122c109dd0b9b7ead" alt="The Web Tracking settings page, showing the generated tag, the account's tracking key, and the two switches that control what the tag sends" width="1136" height="844" data-path="images/mk/web-edge/setup-web-tracking.png" />
</Frame>

## Install the tag

<Steps>
  <Step id="open-web-tracking" title="Open the Web Tracking settings">
    In allGood, go to **Settings → Web Tracking**.
  </Step>

  <Step id="issue-a-tracking-key" title="Issue a tracking key">
    If the page shows **Issue key** instead of a key, click it. That mints your account's key — a value beginning `agsk_` — and the tag snippet appears above it, filled in with your domain and your key.

    There is one key per account, not one per website.
  </Step>

  <Step id="turn-on-sending" title="Turn on Send events to allGood">
    Under **What the tag does**, switch **Send events to allGood** on. On a new account it starts off, and while it's off the tag sends nothing at all.

    Watch the status chip on the screen. It reads **Publishing…** while the change travels out to allGood's edge network, then **Live at the edge**. Until it's green, the previous setting is still the one being enforced.
  </Step>

  <Step id="check-your-origin" title="Check the site is on your allowed origins list">
    Open **Settings → Web Edge** and look at **Allowed origins**. The site you're about to add the tag to has to be listed there, written exactly as the browser sees it — scheme included, no trailing slash, no path.

    `https://www.brand.com` and `https://brand.com` are different origins. Add each one you actually publish from.
  </Step>

  <Step id="copy-your-tag" title="Copy your tag">
    Back on **Settings → Web Tracking**, click **Copy** under **Your tag**. The snippet looks like this, with your real domain and key already filled in:

    ```html theme={null}
    <script src="https://mk.brand.com/_ag/v1.js"
            data-ag-key="agsk_..." async></script>
    ```
  </Step>

  <Step id="paste-into-your-pages" title="Paste it into your pages">
    Paste the tag into the `<head>` of every page you want tracked, before the closing `</head>`, and publish. More detail on placement and page views: [Install the tag](/mk/developer/web-edge/install-the-tag).

    Keep the `async` attribute. Including the tag twice on one page is harmless — the second copy sees the first and stops.
  </Step>

  <Step id="verify-it-works" title="Check that it's working">
    Load one of your pages and open the browser's developer tools.

    * **Console** — no message beginning `[allGood]`. If there is one, it names the exact problem; the most common is an origin that isn't on the allowed list.
    * **Console** — typing `window.allgood.version` returns a version string, which confirms the script loaded.
    * **Network** — filter on `_ag`. You should see `/_ag/rc` return `200`, and, once consent allows it, `/_ag/e` return `202`.

    You can also click **Open test page** on the Web Tracking screen ([more on testing](/mk/developer/web-edge/test-your-setup)). That opens a page allGood hosts on a genuinely separate domain, running the real tag against your real settings, so it exercises the whole path end to end.
  </Step>
</Steps>

<Note>
  Can't edit the `<head>` directly? The [**Install with Google Tag Manager**](/mk/developer/web-edge/install-with-gtm) button on this screen generates a GTM template with your domain and key already built in. The result is identical to pasting the snippet.
</Note>

## What the two switches do

Both live under **What the tag does**.

**Send events to allGood** is the master switch. While it's off, nothing is recorded — not page views, and not any custom events your developers send. Turning it back on resumes tracking straight away. Form submissions are unaffected either way; they don't use the tracking key at all.

**Automatic page views** controls only the page views the tag records by itself. On, it records one when a page loads and again on every route change in a single-page app. Off, it records none of its own, but custom events your team sends still arrive. Turn it off if your site changes its URL for reasons that aren't really navigation, and you'd rather record page views deliberately.

## About your tracking key

The key sits in the `data-ag-key` attribute of every page carrying your tag, so anyone who views your page source can read it. **It isn't a secret, and it doesn't need protecting.** It says which allGood account is sending; it doesn't authorise the sender.

What actually controls who can send is the [allowed origins list](/mk/developer/web-edge/allowed-origins), together with [bot protection](/mk/developer/web-edge/bot-protection) for anything that isn't a browser.

Beside the key, allGood shows a short `keyId` — the first characters of the key's fingerprint. Quote that to support when you need to say *which* key is in force, rather than pasting the key itself.

[Rotating and revoking](/mk/developer/web-edge/rotate-or-revoke-key) the key are covered separately. In short: rotating never drops traffic, because the old key keeps working until the new one reaches the edge, and revoking stops event tracking immediately while leaving form capture running.

## Consent

Tracking is gated on your visitors' consent, configured under [Consent Provider](/mk/developer/web-edge/consent-provider). Under the default posture the tag holds page views and custom events in memory until your consent platform says yes, then sends everything it held.

This is the usual explanation for "the tag is installed, the console is clean, and nothing is arriving": the consent signal never became a yes, so the tag waited and then quietly stopped. Setting your consent global to `true` in the console and reloading is the fastest way to confirm that's the cause.

Form submissions are never gated on this. A submission is something the visitor deliberately chose to do.

## If it isn't working

| What you see                                          | Usually means                                                      | Fix                                                                             |
| ----------------------------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------------- |
| A `[allGood]` message in the console about the origin | The site isn't on the allowed origins list                         | Add the origin exactly, then reload once the sync chip is green                 |
| No `/_ag/e` request at all, and no errors             | The tag is holding events, waiting on consent                      | Check your consent platform is writing the signal allGood is configured to read |
| `/_ag/e` returns `403`                                | Tracking is off, or the key is wrong or revoked                    | Check **Send events to allGood** is on, and re-copy the tag                     |
| Page views on load but not on navigation              | The site routes on the URL hash, which isn't treated as navigation | Turn off automatic page views and record them from your own route handler       |
| A settings change that "didn't take"                  | The edge hadn't caught up yet                                      | Wait for the chip to read **Live at the edge**                                  |

If the console is clean, the switch is on, and events still aren't arriving, see [Troubleshooting](/mk/developer/web-edge/troubleshooting) or contact [support@allgoodhq.com](mailto:support@allgoodhq.com) with the page URL, the `keyId` from the Web Tracking screen, and anything the console printed.
