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.
TYPO3 9 LTS ships a new module called Sites.
This is the central place to define all relevant information regarding domains and available languages.
Extensions can extend the site configuration with additional fields. To be able to provide custom configuration, the following file needs to placed in your site-package extension at Configuration/SiteConfiguration/Overrides/sites.php.
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 value of the new field can be retrieved in various ways.
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.
The shortest possible snippet can look like this:
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.