Are you feeling overwhelmed by the world of website tracking and data collection? You’re not alone. With evolving privacy regulations and the eventual phase-out of third-party cookies, understanding how to implement website tagging properly can seem daunting. But don’t worry, Google has provided two powerful tools – gtag.js and Google Tag Manager – to simplify the process.
What is gtag.js?
gtag.js is a JavaScript tagging framework that allows your website to communicate and send data to various Google products like Google Ads and Google Analytics 4 (GA4). It acts as a universal adapter, replacing the need for multiple tags for each Google service.
For marketers without dedicated web developers or those preferring a hands-off approach to code, gtag.js provides a streamlined way to collect important user data and measure website performance. As third-party cookies get phased out, relying on first-party data through gtag.js will become crucial for accurate measurement.
What is Google Tag Manager?
Google Tag Manager (GTM) takes website tag management to another level. It’s a free tool that centralizes all of your website tags in one easy-to-use interface. With GTM, you can add, edit, and remove tags across your site without actually editing the site’s code.
GTM’s versatility is one of its biggest strengths. It supports not only Google tags like gtag.js, but also a wide array of third-party tags for things like Facebook Ads, LinkedIn analytics, and more. This makes GTM an essential tool for comprehensive data collection and marketing efforts.
The Power of Using gtag.js and GTM Together
While you can implement the gtag.js code directly on your site, using it in conjunction with Google Tag Manager provides more flexibility, control, and advanced features:
– Centralized tag management across your site(s)
– Easy updating of tags without editing code
– Advanced tag firing rules and version control
– Collaboration and workspace sharing
– Support for server-side tagging
– Management of third-party tags beyond just Google
Implementing gtag.js Through Google Tag Manager
Now let’s walk through how to set up the powerful duo of gtag.js and GTM properly:
1. Create a Google Tag Manager Account
Sign up for a free GTM account at tagmanager.google.com. Create a “Web” container for your website.

2. Install the GTM Code Snippets
Copy the two GTM code snippets provided. Paste the first snippet high in each page’s <head> section. Paste the second snippet immediately after the <body> tag.

3. Create the gtag.js Tag in GTM
Within your GTM container, create a new tag titled “Google tag.” Choose “Google tag” as the tag type and enter your Google tag ID (find this in Google Ads or GA4).

4. Set Up the Trigger
Next, set up a trigger for when this tag should fire. The most common is the “All Pages” trigger to have it fire across your whole site.

5. Save and Publish in GTM
Save your new tag and trigger settings. Then, publish your changes in GTM to make them live on your site.
6. Verify Using Tag Assistant
Use the free Google Tag Assistant Chrome extension to scan your website and verify that the gtag.js tag is being detected and firing events properly.

Building a Solid Tracking Foundation
By implementing gtag.js through the powerful Google Tag Manager system, you’re setting up a flexible, privacy-focused foundation for accurate website tracking. From basic pageview tracking to advanced e-commerce and conversion measurement, this combo enables comprehensive data collection.
And the best part? You’re doing it in a marketer-friendly way without heavy reliance on developer resources or code changes. So take control of your website data, drive insights, and optimize your marketing efforts like never before!
