How to connect Google Tag Manager to your website step by step

By: Rodrigo A. (Analytics Lead) Updated: August 2026 8 min read Google Tag Manager Certified Verified GA4 & Meta Setup
Key Takeaways in 60 Seconds
  • Full Marketing Autonomy: GTM removes engineering bottlenecks when deploying Google Ads tags, Meta Pixels, and custom events.
  • Page Speed Protection: Asynchronous tag loading inside a centralized container minimizes Total Blocking Time (TBT).
  • DataLayer Variables: Safely pass dynamic e-commerce data (transaction totals, currencies, user identifiers) to ad networks.
  • Live Debugging: Tag Assistant Preview mode lets you verify firing rules before deploying tags to production.
Web Analytics Dashboard for Conversion Tracking

If you're tired of calling your developer every time you need to install a Facebook pixel, a Google Ads tag, or a conversion event, this technical step-by-step guide is for you.

Google Tag Manager (GTM) is a free tag management platform that allows you to deploy marketing and measurement scripts quickly, safely, and centrally without modifying your underlying source code on every iteration.

1. Step 1: Create your GTM Account and Container

Navigate to tagmanager.google.com using your corporate Google Workspace account. Create a new account under your company name, select Web as the target platform, and generate your container identifier (GTM-XXXXXXX).

Governance Tip: Always use a dedicated corporate admin account to maintain control over GTM permissions and user roles.

2. Step 2: Install the <head> and <body> Snippets

GTM provides two JavaScript code snippets:

  • Snippet 1 (<head>): Place as high as possible in the <head> element to initiate tracking as early as possible during the DOM lifecycle.
  • Snippet 2 (<body>): Place immediately after the opening <body> tag to provide an iframe fallback for scriptless environments.
Desarrollo Web con Código Limpio y Eficiente

If you use WordPress, integrate GTM via GTM4WP or inject snippets directly into your child theme's header.php.

3. Step 3: Configure GA4 and Meta Pixel Tags

In your GTM workspace, create a new Google Tag with your GA4 Measurement ID (G-XXXXXXXXXX) triggered on Initialization - All Pages. For Meta, create a Custom HTML tag with the base Pixel snippet (or use the community template) triggered on All Pages.

4. Step 4: Debug and Verify with Google Tag Assistant

Click Preview in GTM to launch Google Tag Assistant. Browse your website in the debug window to confirm that your tags fire on the expected triggers with the correct dataLayer parameters before publishing.

5. Step 5: Container Governance and Best Practices

  1. Standardized Naming: Use clear conventions like GA4 - Event - Contact Form or Meta - Pixel - PageView.
  2. Version Control: Always write descriptive version notes before publishing changes.
  3. Prune Dead Tags: Delete paused campaign tags and obsolete scripts to avoid DOM clutter.
Rodrigo A.
Lead Author Analytics Specialist

Web Analytics & Tag Management Engineer at Agencia Cohete

Specialist in frontend measurement architectures, dataLayer engineering, and conversion synchronization across Google Ads, Meta, and TikTok.

Analytics Setup Turnkey Tag Deployment

Need help configuring complex conversion events?

We set up your GTM container, GA4 enhanced e-commerce, and CAPI pipelines to ensure clean data reaches your CRM.

Help Categories
Strategy Tutorials Hosting Sales Analytics

Is your web not converting?

We perform technical audits to find budget leaks.

Free Audit