Embed Google Tag Manager by extending TYPO3 Site Module

This blog post describes how the Sites module of TYPO3 9 can be extended and how the information can be extracted and used later on.

Additional tab with one extra field to define the Google Tag Manager code

TYPO3 9 LTS ships a new module called Sites.
This is the central place to define all relevant information regarding domains and available languages.


You will recognize the syntax from writing TCA code as it is very similar.
However, there are certain limits regarding the available field types which are written down in the docs. In short, you can use input & select fields and checkboxes but for example no relations.



The SiteFinder can be used in Frontend or Backend to retrieve a proper Site object — either by providing a page id, root page id or the site identifier.
The Site itself includes all information which is persisted in the Sites module.


lib.test = TEXT
lib.test.data = site:googleTagManager

A real-world example would be the following which retrieves the value and uses it for including the Google Tag Manager into the TYPO3 site.

Happy coding!

Software developer, primary working with the CMS TYPO3, freelancer and employed at https://www.studiomitte.com in Linz (Austria)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store