Google Analytics ID Validator
Validate Google Analytics ID formats: UA-XXXXX-Y (universal) and G-XXXXXXXXXX (GA4). Identifies type.
Google Analytics IDs: GA4, Universal Analytics and the road to deprecation
A Google Analytics ID is the unique token that ties your website or app to a property inside the Google Analytics platform. Without a valid ID the gtag.js snippet has nowhere to send hits, and reports stay empty. Two prefixes coexist in the wild because Google has migrated through several generations of the product, and pixels of the older generation are still embedded in millions of pages.
The current generation is GA4 (Google Analytics 4), launched in October 2020 and made mandatory on July 1, 2023, when Universal Analytics stopped processing new hits. The legacy generation is Universal Analytics (UA), retired but still occasionally pasted into new themes and CMS templates by mistake. Google Tag Manager (GTM) uses a third, unrelated ID format (covered in our dedicated GTM validator).
GA4 Measurement ID format
- Prefix
G-followed by exactly 10 alphanumeric characters, upper case and digits only. - Regex:
^G-[A-Z0-9]{10}$. - Example:
G-XXXXXXXXXX. The 10 characters are pseudo-random and carry no public meaning. - Each GA4 property has one Measurement ID per data stream (web, iOS, Android). A single property can therefore expose multiple IDs.
Universal Analytics (legacy) format
- Prefix
UA-followed by an account number (6 to 10 digits) and a property suffix (1 to 3 digits). - Regex:
^UA-\d{4,10}-\d{1,3}$. - Example:
UA-12345678-1. - Status: deprecated July 1, 2023. Historical data was kept read-only until July 2024, then permanently deleted. New UA properties cannot be created.
Installing GA4 with gtag.js
The official snippet is a two-line block placed in the <head> tag right after the opening tag:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
The same config call accepts options such as send_page_view: false for SPAs, anonymize_ip: true for stricter privacy posture, and cookie_flags: 'SameSite=None;Secure' for cross-domain scenarios.
Event-based model: how GA4 differs from UA
Universal Analytics revolved around pageviews and sessions. GA4 flips that: every interaction is an event with parameters. A pageview is just an event named page_view. This unifies web and app tracking in one schema and enables granular funnels, but it forces teams to redesign dashboards, conversions and audiences when migrating from UA.
Key consequences: bounce rate is replaced by engagement rate, real-time reports use a 30-minute rolling window, and BigQuery export is free (capped at 1 million events per day on the standard tier) โ a feature reserved for the paid GA360 in the UA era.
Server-side tracking and the Measurement Protocol
Browser-based tracking is increasingly blocked by ad blockers (uBlock Origin, Brave Shield), Apple ITP and corporate proxies. GA4 ships a Measurement Protocol that lets you POST events directly from your backend (Node.js, Python, Cloudflare Worker) using an api_secret generated alongside the Measurement ID:
POST https://www.google-analytics.com/mp/collect
?measurement_id=G-XXXXXXXXXX&api_secret=...
Combined with a server-side GTM container, this strategy delivers cleaner data, faster page loads, and resilience to client-side blockers โ at the cost of running infrastructure (Cloud Run, Vercel, Fly.io).
Privacy and consent (LGPD, GDPR, ePrivacy)
Google Analytics drops cookies (_ga, _ga_<CONTAINER>) and pings third-party servers, which under LGPD (Brazil), GDPR (EU) and the ePrivacy Directive requires explicit user opt-in before the script fires. Recommended pattern:
- Defer the
gtag.jsscript until the user accepts cookies via a CMP (Cookiebot, OneTrust, Iubenda, Osano). - Enable Consent Mode v2 so analytics_storage and ad_storage are set explicitly.
- Avoid collecting PII (email, CPF, phone) as event parameters โ Google can ban the property under its Terms of Service.
Brazilian context and privacy-friendly alternatives
Surveys by BuiltWith and W3Techs show that over 80% of Brazilian websites still rely on Google Analytics โ by far the dominant analytics stack in the country. For teams that prefer to reduce dependence on Google or simplify LGPD compliance, the main contenders are Plausible (cookieless, EU-hosted), Fathom, Simple Analytics and the self-hosted Matomo. None of them use the G- prefix, so this validator will (correctly) reject their IDs.
FAQ
Does Universal Analytics still work?
No. UA stopped processing hits on July 1, 2023 and historical data was deleted in July 2024. Any UA- snippet in production today is dead weight and should be removed.
Is user consent really mandatory in Brazil?
Yes. Under the LGPD (Law 13.709/2018), tracking cookies require a valid legal basis โ in most B2C scenarios that means explicit consent. Pair GA4 with a CMP and enable Consent Mode v2 to stay compliant.
Is BigQuery export really free with GA4?
Yes for standard properties, with a daily ceiling of 1 million events. Beyond that you need GA360 or you must downsample. The data lands in your own BigQuery project and incurs storage and query costs there.
Can I use the same Measurement ID in staging and production?
It is a common anti-pattern. Mixed traffic pollutes funnels, audiences and attribution. Use separate properties (one ID per environment) or read the ID from an environment variable at build time.
Does this validator check whether the ID actually exists in Google?
No. The check is purely a regex over the format. To confirm the property is real and receiving data, open the GA4 DebugView or run a test event from the Measurement Protocol playground.
Related Tools
CPF Validator
Validate Brazilian CPF numbers instantly using the official algorithm. Useful for testing document validation in applications. No data sent to servers.
Batch CPF Validator
Validate a list of CPFs (one per line) and see which are valid and which are not. No data sent to servers.
Batch CNPJ Validator
Validate a list of CNPJs (one per line) with a summary of valid, invalid and total. No data sent to servers.