Add Google Tag Manager to Joomla

Every marketing tool you try wants its own tracking code in your site's head, and every time you add one you are back in your template files or waiting on a developer. Analytics, pixels, heatmaps, chat widgets, the list keeps growing and so does the mess. Google Tag Manager replaces all of them with a single container you manage from a web interface, and adding Google Tag Manager to Joomla doesn't have to mean another plugin. Hopefully, you don't need an extra plugin. You can add GTM to your Joomla site using Tassos Code Snippets.

What is Google Tag Manager

Google Tag Manager is a free tag management system by Google. You install one container on your site, then add, edit, and remove tracking tags from the GTM interface without ever touching your site's code again.

How to get the Google Tag Manager Container ID

You need a Google account and a GTM container.

  1. Go to Google Tag Manager and sign in.
  2. Click Create Account, or open an existing account.
  3. Enter an account name, then a container name, and choose Web as the target platform.
  4. Accept the terms of service. GTM immediately shows you the install code.
  5. Copy your Container ID. It looks like GTM-XXXXXXX and appears at the top of the container.

How to Add Google Tag Manager to Joomla

Google Tag Manager needs two pieces of code: a script in the head and a <noscript> fallback right after the opening <body> tag. That means two snippets.

Snippet 1: the head code

  1. Install Tassos Code Snippets if it is not installed already.
  2. Go to Joomla Administrator.
  3. Open Components → Tassos Code Snippets.
  4. Click New.
  5. Give your snippet a descriptive title like "Google Tag Manager - Head".
  6. Select HTML snippet type.
  7. Paste the following code, replacing GTM-XXXXXXX with your actual Container ID:
    <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>
  8. Select Site Header as the Insertion Method.
  9. Publish the snippet.

Snippet 2: the body code

  1. Click New again.
  2. Give this snippet a title like "Google Tag Manager - Body".
  3. Select HTML snippet type.
  4. Paste the following code, again replacing GTM-XXXXXXX with your Container ID:
    <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXXX"
    height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
  5. Select Site Body as the Insertion Method, which places the code right after the opening <body> tag exactly where Google expects it.
  6. Publish the snippet.
  7. Optionally, open the Conditional Logic tab on either snippet to restrict which pages they run on. Leave it empty to run site-wide. Learn more in Using Snippet Logic.

Congrats! You've successfully added Google Tag Manager to your Joomla site without installing another plugin.

From here on, every new tag goes into your GTM container, not into your Joomla site. If you already have Google Analytics installed as a separate snippet, unpublish it before adding it inside GTM, otherwise you will count every page view twice.

Verify it Works

Open your GTM container and click Preview. Enter your site URL and connect. The Tag Assistant window shows the container firing on your page along with every tag inside it. You can also view your page source and search for GTM-, which should return both the head script and the body iframe. If Preview cannot connect, confirm both snippets are published and that the Container ID matches in both.

For more information about snippet types and insertion methods, visit our documentation: https://www.tassos.gr/docs/tassos-code-snippets/

Last updated on Jul 29th 2026 15:07