The two attributes
The key can also ride in the URL as
?k=…. That form exists for Google Tag Manager, which can inject a URL but can’t set an attribute.
Where to put it
In<head>, with async, on every page you want tracked.
Loading the script twice on one page is safe — the second copy sees the first and stops. Loading it earlier doesn’t make anything send earlier, because it fetches a small configuration file first and sends nothing until that lands.
What happens on load
- It reads its own address and key.
- It finds every form on the page marked for allGood and binds them.
- It fetches its configuration in one request covering the whole page.
- It adds the honeypot field, and the bot-check widget on forms that need one.
- It starts watching for navigation, so single-page-app route changes count as page views.
- It records the first page view — or holds it, if consent hasn’t been answered.
- It fires an
allgood:readyevent on the page.
Page views
With Automatic page views on, the script records a page view carrying the URL, path, title, referrer, and anyutm_ parameters or advertising click ids it finds.
Repeat views are not double-counted. A page view is recorded once per unique path and query string, so a route change back to the same place within one page load doesn’t record a second one. A full reload does.
Single-page apps work without configuration. Anything using the browser’s History API — React Router, Next.js client navigation, Vue Router and so on — produces page views on route change, including back and forward.
Hash changes don’t count as navigation.
#section anchors don’t produce a page view, because the path hasn’t changed. If your app routes on the hash, turn off automatic page views and record them yourself with track().Personal data in URLs is removed
Query values that look like an email address, or that are very long, are replaced before the URL is stored. The key stays, so you can see something was there. Don’t put personal data in a URL and expect it to survive.Pages allGood hosts
Landing pages on your allGood subdomain record a page view without any script at all, on every visit. So a hosted page doesn’t need the tag for page views. It does still need it foridentify() and track(), and for form capture.
Content Security Policy
If your site sets a CSP, the tag needs:Check it worked
- Console — no message beginning
[allGood]. If there is one, it names the exact problem. - Console —
window.allgood.versionreturns a version string. - Network — filter on
_ag; the configuration request should succeed, and once consent allows it, so should the event request.