As a site grows, it collects codes: Google Analytics, ad pixels, chat widgets, conversion scripts. Each one means asking a developer to edit the template and redeploy, and eventually the page head is full of scripts nobody remembers adding. Google Tag Manager (GTM) puts all of this in one place: you install a container code once and manage everything else through a web interface.
How GTM works
At the core is a container, a set of settings for your site with an ID like GTM-XXXXXXX. On each page load the browser fetches the current configuration and fires the configured codes at the right moments. Adding a new script no longer requires changing site files, only creating and publishing a tag. Three concepts drive everything. A tag is the code that runs, such as the Google tag for GA4 or a custom HTML script. A trigger decides when it runs: all pages, a specific page, a link click, a form submission or a scroll depth. A variable supplies values such as page URL or clicked link URL; some built-in variables are disabled by default and must be enabled under Variables.
Installing the container
After creating an account and container at tagmanager.google.com, you get two snippets. The first goes as high as possible in the <head>:
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
<!-- End Google Tag Manager -->
The second goes right after the opening <body> tag, for browsers without JavaScript:
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
Place them in a shared template such as header.php, or use a header-and-footer plugin on WordPress, and replace the placeholder ID with your own.
First tag: GA4 through GTM
Create a tag of type "Google tag", enter the GA4 measurement ID starting with G-, and attach the "Initialization - All Pages" or "All Pages" trigger. A common mistake is keeping the old gtag.js code in the template while also adding GA4 in GTM, which counts every page view twice. Choose one.
Example: tracking Telegram button clicks
A hotel in Bukhara gets most enquiries through a "Message us on Telegram" button and wants to count clicks without writing code:
- Enable the built-in
Click URLvariable. - Create a "Just Links" trigger where
Click URLcontainst.me. - Create a GA4 event tag named
telegram_clickwith alink_urlparameter set to{{Click URL}}. - Attach the trigger and save.
Mark telegram_click as a key event in GA4 to see which traffic sources produce enquiries.
Preview and publishing
Changes sit in a workspace until published. Click Preview to open Tag Assistant, which loads your site in debug mode and shows which tags fired on each action. Once the Telegram tag shows "Fired", click Submit and give the version a clear name. GTM keeps every published version, so rolling back takes a few clicks.
Security and housekeeping
Anyone with GTM access can inject JavaScript into your site. Add only trusted people, separate edit and publish permissions, and remove agencies or freelancers when work ends. Name tags clearly, for example "GA4 - Event - Telegram click", and delete unused ones, since extra tags slow pages down. Overall speed matters too; sites on sayt.uz hosting run on servers in Uzbekistan and load quickly for local visitors.