Google tag (gtag.js)
Google's page script for analytics and ads; sets IDs like _ga and _gcl_au in the browser.
In one line
Can tell Google about your visits and actions on a site that uses the tag
Google's page script for analytics and ads; sets IDs like _ga and _gcl_au in the browser.
_ga (2 years, capped at 400 days in Chrome) joins visits into one user, _gid lasts 24 hours, _gcl_au 90 days for ad conversions. Consent Mode v2 changes what is sent if the person declines.
What it can and can't do
What the user does: Nothing. It happens when you open a page with the Google tag
It can
- Set IDs such as _ga and _gcl_au in your browser
- Report page views, clicks and purchases to Google
- Link visits over time with the same ID
- Feed Google Analytics and Google Ads
It cannot
- Run on sites that do not include the tag
- See other sites unless they also use it
- Keep the ID if you clear cookies or block the script
- Know your name unless you sign in to Google or the site shares it
How it differs between platforms: Safari and Firefox limit how long some of its cookies last. Chrome keeps them for longer.
Browser support
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 1 | 2008-12-11 | Script runs in any browser, cookie lifetimes vary |
| Edge | Supported | 1 | Not listed | Script runs in any browser, cookie lifetimes vary |
| Firefox | Supported | 1 | 2004-11-09 | Script runs in any browser, cookie lifetimes vary |
| Safari | Supported | 1 | 2003-06-23 | Script runs in any browser, cookie lifetimes vary |
| Safari on iPhone | Supported | 1 | 2007-06-29 | Script runs in any browser, cookie lifetimes vary |
| Chrome on Android | Supported | 1 | Not listed | Script runs in any browser, cookie lifetimes vary |
| Samsung Internet | Supported | 1 | 2013-04-27 | Script runs in any browser, cookie lifetimes vary |
How a site asks for it
| API | gtag('event', ...); requests to google-analytics.com/g/collect |
| How access is granted | none |
| What the user sees | None |
| Needs a secure context (HTTPS) | No |
| Needs a user gesture | No |
| How long it lasts | _ga about 2 years (400 days in Chrome), _gid 24 hours, _gcl_au 90 days |
| How to take it back | Clear site data, browser privacy settings |
| Inside an iframe | Not listed |
Data you get
What comes back: Analytics events
Shape: event
How often: per action
No individual data fields. The signal is the access itself.
Technical limits
- Safari caps JS set cookies at 7 days
- Consent Mode modelling fills gaps for declined users
- Blocked by many blockers
The story
What it is
Google's page script for analytics and ads that sets IDs in your browser.
For you
You do not see the script. It sets small files like _ga that tell Google you are the same visitor, and counts what you do. If you decline cookies, Consent Mode can still send limited signals.
For makers
The Google tag is the base for Analytics and Google Ads on a large share of the web. It counts visits, sales and ad clicks in one tool. Consent Mode lets sites model results when people say no.
Where you see it
| Type | Example | Apps |
|---|---|---|
| analytics | A blog owner sees how many people visited today, which pages they read and where they came from. | Google Analytics |
| ads | A shop sees which Google ad made each sale, using the _gcl cookies and click IDs. | Google Ads |
| games | A browser game site sees how many players come from a search, and how long they stay. | CrazyGames, Poki |
| shopping | A retailer builds a remarketing list of people who looked at a product. | Shopify, Wayfair |
| media | A news site measures which stories keep readers longest, to decide what to write. | BBC, The Guardian |
| security | Consent Mode sends pings with no cookies if a person declines, which Google uses to model the missing data. | None named |
Risks
- Follows you across visits
- Google sees data from huge number of sites
What the platform says
- Google: Google tag cookies. Google documents the cookies like _ga that its tag sets to measure visits and ad results.
Good uses and abuse
Legitimate uses
- Analytics, conversion measurement
Known abuse
- Cross-site ad profiles and remarketing lists
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 4 of 5 | How revealing the data is |
| Utility | 5 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | Not rated | Rough identifying entropy, when known |
History
- 2023-07, all: Universal Analytics stopped processing; GA4 only
- 2023-11, all: Consent Mode v2 required for EEA ad personalisation from Mar 2024
Related capabilities
Related
- Google enhanced conversions. Can match a scrambled email or phone from your checkout to a Google account
- Ad click IDs (gclid, fbclid, msclkid and more). Can tag your ad click so a later purchase links back to that exact ad
Sources
How well checked: Based on official documentation.