Add Google Analytics to Joomla
Your Joomla website gets traffic every day, but you have no idea where visitors come from, what they do, or how long they stay. Without tracking in place, you're making decisions based on gut feeling instead of data. Adding Google Analytics to Joomla is the fix, and you don't need a dedicated plugin. You can add Google Analytics to your Joomla site using Tassos Code Snippets.
Get the Google Analytics Measurement ID
You need a Google Analytics account and a GA4 property. If you haven't set one up yet, follow these steps.
- Go to Google Analytics and sign in.
- Click the Admin gear icon in the bottom-left corner.
- Under Property, click Data Streams.
- Click on your website's data stream.
- Copy the Measurement ID (it starts with
G-). You'll need this in the next step.
Install Google Analytics in Joomla
Google Analytics is a piece of code you add to the header section on every page of your Joomla website. To install it, follow the steps below:
- Install Tassos Code Snippets if it is not installed already.
- Go to the Joomla Administrator.
- Open Components → Tassos Code Snippets.
- Click New.
- Give your snippet a descriptive title like "Google Analytics Tracking".
- Select HTML snippet type.
- Paste the following code, replacing
G-XXXXXXXXXXwith your actual Measurement ID:<!-- 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> - Select Site Header as the Insertion Method.
- Publish the snippet.
Congrats! You've successfully added Google Analytics to your Joomla site without installing another plugin.
Verify it Works
After publishing the snippet, visit your website to trigger a page view. Then open your Google Analytics account and go to Reports → Realtime. If you see an active user, the tracking code is working correctly. If nothing shows up, wait a minute and refresh, or check that the snippet is published and set to Site Header.