Using Tag Manager
From Joomla! Documentation
What is Google Tag Manager?
Google Tag Manager is a way to combine all your tracking and marketing scripts into one, version controlled container which is inserted into your site, calling one single file instead of multiple files which can slow your site down.
It also allows you to fire specific tags - such as conversion tags - on specific pages, without having to edit the code of the component or extension that powers the page.
Configuring Google Tag Manager
Before you can use Google Tag Manager you need to sign up at http://www.google.com/tagmanager
Once you have a Google Tag Manager account set up, you'll log in and see the dashboard from which you can create a new account.
Generally you should create a new account for each client you work with. One account can have multiple containers, and many users with the following levels of access:
- View only
- View and edit
- View, edit, delete and publish
Installing Tag Manager on your Joomla website
Inserting Google Tag Manager into your website requires either editing your template file, or using an extension to insert the container in the correct location.
There are pro's and con's for both approaches - inserting into the template requires you to edit the code of the index.php file, however it means it's not easy to remove or unpublish accidentally. Using a plugin requires an additional call on page load, and can potentially have compatibility issues going forward if code changes are necessary.
Google Tag Manager Extensions
There are several extensions you can use to embed the Google Tag Manager code - browse them on the Joomla! Extensions Directory.