Google tag (gtag.js)
The Google tag (gtag.js) is one JavaScript tag that sends website data to Google products such as Google Ads and Google Analytics 4, which Google calls its destinations.
In plain words
Instead of a separate snippet for each Google product, the Google tag loads once per page and sends events to every destination linked to its tag ID: page views, purchases, sign-ups. Its ID starts with G- for a GA4 web stream or AW- for a Google Ads account; several destinations can share one tag. It replaced the older "global site tag" name and is managed in the Google tag settings inside Google Ads or GA4. It also acts as Google Ads' conversion linker: it stores the ad click id (gclid) in a first-party cookie so a later purchase can be tied to the click. The Google tag is a browser tag, so ad blockers, browser privacy features and missing consent can stop it.
What the Google tag does
- Measures: page views and, with event calls, actions such as
add_to_cartandpurchase. - Sends to destinations: one tag can feed a GA4 property and a Google Ads account; a change in the tag settings applies to all of them (About the Google tag).
- Links ad clicks: it keeps the gclid (or gbraid/wbraid) from the landing URL in first-party cookies, which Google Ads conversion tracking reads.
- Handles consent: with Consent Mode it adjusts what it stores and sends to the visitor's choice.
Benefits of using the Google tag
- One tag instead of several, so fewer scripts and fewer code changes when you add a Google product.
- Settings such as automatic event detection, cross-domain measurement and user-provided data (enhanced conversions) are switched on in the tag settings, without editing the site.
- Tags and destinations can be combined, so data reaches GA4 and Google Ads consistently.
- It supports Consent Mode, which Google requires for measuring and personalising ads for visitors in the European Economic Area.
Google Tag Manager vs the Google tag
| Google tag (gtag.js) | Google Tag Manager (GTM) | |
|---|---|---|
| What it is | A tag for Google products | A tag management system that loads many tags |
| Tags it handles | Google Ads, GA4 and other Google destinations | Google and third-party tags (Meta, TikTok, Pinterest, your own scripts) |
| How you change it | Code on the page plus the tag settings in Google Ads or GA4 | A web interface with triggers, variables and versions |
| Best for | A site that only needs Google measurement | A site with many tags, or a team that wants changes without deploys |
| Server-side option | No | Yes, with a server container |
Swipe the table sideways to see every column.
They are not either-or: a GTM container can load the Google tag. Pick one place to manage it, or purchases get counted twice. See Google Tag Manager on Shopify.
How to add a Google tag to your website
- Create or find the tag
In Google Ads (the Google tag section under Tools) or GA4 (Admin › Data streams › your web stream › View tag instructions), find the tag ID: AW-… or G-….
- Install it
Paste the snippet right after the opening head tag of every page, or install it through your platform. On Shopify, the Google & YouTube app connects GA4 and Google Ads without editing the theme.
- Add the conversion event
For Google Ads, send the purchase with its conversion label, value, currency and order id (transaction_id), so duplicates are removed.
- Set up consent
Send a Consent Mode default before the tag loads and an update when the visitor chooses.
- Check it
Use Tag Assistant, and check the tag status in Google Ads or the realtime report in GA4.
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-123456789"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-123456789');
</script>The snippet's structure follows Google's gtag.js documentation. Shopify's checkout runs in a sandbox, so a tag pasted into the theme does not see purchases; use an app or a custom pixel. See Google Ads conversion tracking on Shopify and Google tag warnings.
Where the Google tag falls short
As a browser tag it misses purchases when the tag is blocked, the browser limits cookies, the visitor declines consent or the thank-you page does not load. Google Ads enhanced conversions and server-side uploads of conversions with the click id make up for part of that. See server-side tracking.
In ROASaurus
Connections › Tracking & destinations- Open Connections › Tracking & destinations and add the Google Ads destination with your conversion ID (the number after AW-) and purchase conversion label.
- With the visitor's consent, ROASaurus loads the Google tag on the storefront as conversion linker, so the gclid or gbraid of an ad click is kept in first-party cookies, and in Shopify's checkout to send the purchase with enhanced conversions allowed.
- Once the Google Ads account is connected for ad spend with the Data Manager grant, ROASaurus also sends each purchase server-side with the click id.
- Check Data quality › Overview for the share of orders Google Ads accepted, and Data quality › Deliveries for each server event and Google's answer.

Start freeOpen the live demo14-day trial of every feature, no credit card.
Read more
- Google Tag Manager on Shopify
- Google Ads conversion tracking on Shopify
- Google tag warnings
- GA4 for Shopify
- Google Ads enhanced conversions on Shopify
- BFCM tracking checklist
- Klaviyo and Shopify tracking
- Tracking audit
- Google Ads integration
Sources
- Tag Manager Help: About the Google tag
- Google Tag Platform: gtag.js
- Tag Manager Help: About Google Tag Manager
Related terms
- Click id
A code an ad platform adds to the link of an ad, such as fbclid for Meta or gclid for Google. It lets the platform tie a later purchase to the click.
- Consent mode
Telling ad platforms whether the visitor agreed to marketing cookies, so they use the data only as allowed.
- Server-side tracking
Sending purchases to an ad platform from a server instead of from the visitor's browser. ROASaurus sends each paid order from your shop's own order data, so ad blockers cannot stop it.
- Conversions API
The way an ad platform accepts conversions sent from a server. Meta calls it the Conversions API, TikTok the Events API; most platforms have one.
- First-party data
Data collected on your own domain, by you. Browsers and ad blockers treat it more kindly than scripts loaded from someone else's domain.
- Offline conversions
Conversions that happen after the click but not on the website: a lead that becomes a deal in a CRM, a phone order, a booked appointment or a sale in a physical shop. Importing them tells the ad platform which clicks led to real sales.
What is the Google tag (gtag.js)?
It is a single JavaScript tag from Google that sends website data to Google Ads, Google Analytics 4 and other Google destinations. It was previously called the global site tag.
What is the difference between Google Tag Manager and the Google tag?
The Google tag is a tag for Google products. Google Tag Manager is a tool that manages many tags, including the Google tag and third-party pixels, through a web interface with triggers and versions.
How do I add a Google tag to my website?
Copy the snippet from Google Ads or GA4 and paste it right after the opening head tag on every page, or install it through your shop platform or Google Tag Manager. Then add the conversion events and check them in Tag Assistant.
What do the G- and AW- IDs mean?
G- is the ID of a GA4 web data stream and AW- the ID of a Google Ads account. Both are Google tag IDs, and one tag can send to several destinations.
Do I need the Google tag on Shopify?
For Google Ads and GA4 you need a Google tag or an equivalent. On Shopify the Google & YouTube app or another app installs it, including on the checkout, which a theme snippet cannot reach.
Does the Google tag work with ad blockers?
Often not: ad blockers and some browsers block or limit it. Server-side conversion uploads and enhanced conversions recover part of the conversions it misses.
Every sale, traced to the ad that earned it
Server-side tracking, profit and lifetime value in one app. Free plan, no credit card.