Add Google Analytics to Joomla

Find out where your visitors come from and what they do on your site by adding Google Analytics to Joomla, using one HTML snippet.

Add Google Analytics to Joomla

Your Joomla site gets visitors every day, but you can't tell where they come from, which pages they read or how long they stay. Google Analytics answers those questions for free, and its tracking code belongs on every page of your site. You can add Google Analytics to Joomla with one HTML snippet in Code Snippets.

Get your Measurement ID

You need a Google Analytics account with a GA4 property for your site.

  1. Go to Google Analytics and sign in.
  2. Click Admin, the gear icon in the bottom-left corner.
  3. Under Data collection and modification, click Data streams.
  4. Click your website's stream.
  5. Copy the Measurement ID. It starts with G-.

The snippet code

This is Google's tracking code. In the Site Header location it lands in the <head> of every page.

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

How to add this snippet

  1. Install Code Snippets if it isn't installed already.
  2. Log into your Joomla backend.
  3. Go to Components → Tassos Code Snippets.
  4. Click New.
  5. Enter a title, for example Google Analytics.
  6. Set Code Type to HTML.
  7. Set Insertion Method to Auto-Insert Locations.
  8. Set Location to Site Header.
  9. Paste the code above into the editor.
  10. Replace G-XXXXXXXXXX with your Measurement ID, in both places.
  11. Click Save & Close.

If you use Google Tag Manager, add Google Analytics inside your container instead. Having both counts every visit twice.

Check that it works

  1. Open your site in a normal browser window with no ad blocker.
  2. In Google Analytics, open Reports → Realtime.

You should see yourself as an active user within a minute. If you don't, check that the snippet is published and that the Measurement ID is right in both places.

To manage all your tags from one place, see Add Google Tag Manager to Joomla. To track sales from your ads, see Add Google Ads Conversion Tracking to Joomla. To learn more about how HTML snippets work, read the HTML snippet docs.

Last updated on Oct 15th 2026 14:10