What is Google Tag and how to add it to your website

Modified on Thu, 2 Oct at 12:39 PM

TABLE OF CONTENTS


Intro

The Google Tag (formerly known as the Global Site Tag or gtag.js) is the fundamental piece of code required to use Google's advertising and measurement services on your website.

It acts as a single, unified tagging framework that simplifies connecting your site to multiple Google products.


1. What is the Google Tag?

The Google Tag is a small snippet of JavaScript code that you place on every page of your website.

  • Unified Code: Its primary function is to replace the need for separate tracking codes for every single Google product. You install one Google Tag, and then you can link it to various destinations (Google Analytics, Google Ads, etc.) without having to add more code.

  • Code Structure: It is easily identifiable by the tag ID, which usually starts with G- (for Google Analytics 4) or AW- (for Google Ads).


Example of the Google Tag:

HTML
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'TAG_ID');
</script>


2. Why is it important to have on a website?

The Google Tag is crucial because it is the bridge that allows your website to communicate with your analytics and ad platforms.

Area of ImportanceExplanation
Accurate MeasurementIt allows you to collect essential data like page views, clicks, and scrolls, which is the foundation of Google Analytics 4 (GA4). Without the tag, you collect no data.
Ad Performance & ROIIt enables conversion tracking for Google Ads, allowing you to measure exactly how many sales or leads resulted directly from your ads. This is essential for optimising your ad spend and calculating Return on Investment (ROI).
Future-ProofingIt uses advanced cookies and measurement techniques that are designed to be more resilient against modern browser privacy restrictions and ad blockers, helping to ensure data quality remains high.
Simplified ManagementYou only install the single base tag. You can then manage all linked Google products (GA4, Google Ads, etc.) and their configurations directly from the Google Tag screen within your Google accounts, minimising the need for ongoing code changes.


3. Step-by-Step: How to create and apply

The process of creating and applying the Google Tag typically starts in either your Google Analytics 4 (GA4) or Google Ads account.


Step 1: Create Your Google Tag

The easiest way to get your tag is through a Google Analytics 4 property:

  1. Create/Open GA4: Sign in to your Google Analytics account and access your GA4 property.

  2. Navigate to Tagging Instructions: Go to Admin (gear icon), then Data Streams (under Property settings). Click on your Web Data Stream.

  3. Find Your Tag: Under Google Tag, click View tag instructions. You will see a unique ID beginning with ""G-This is your Google Tag ID.

  4. Copy the Code: Choose the option to Install manually to copy the full code snippet (the one shown in the example above).


Step 2: Apply the Tag to Your Website

The tag needs to be on every page you want to measure.

There are three common methods for application*:

*We have these methods explained below, but we would directly paste the code into your website for you.

MethodBest ForInstructions
1. Direct Code PasteSmall sites, custom sites, or when you are only installing this one tag.Paste the entire code snippet you copied in Step 1 immediately after the opening <head> tag of your HTML on every page of your website.
2. Using a CMS/Website BuilderWordPress, Shopify, Wix, Squarespace, etc.Most platforms have a dedicated field in their settings (e.g., Integrations, Tracking, or Header Code) where you simply paste the G- or AW- ID. The platform handles placing the full code for you.
3. Using Google Tag Manager (Recommended)Complex sites, sites with many tags, or if you plan to track custom events.This is an alternative to the Google Tag (gtag.js) that gives you more control. You install the GTM code once, and then you add the Google Tag within the GTM interface.


Step 3: Verify the Installation

After installing the code, you should check that it is working:

  1. Go to the Google Tag Assistant website (tagassistant.google.com).

  2. Enter your website URL and click Connect. A new window will open with your site.

  3. The Tag Assistant window will show you which Google Tags were successfully found on the page. You should see your G- or AW- ID listed as active.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article