DEPRECATION WARNING

This documentation is not using the current rendering mechanism and is probably outdated. The extension maintainer should switch to the new system. Details on how to use the rendering mechanism can be found here.

Installation

  1. You can download the extension from the TYPO3 Extension Repository (TER).
  2. Add the static template (Google Tag Manager) to your page tree template.
../_images/IncludeStaticTemplate.png
  1. Configure the GTM (Google Tag Manager) ID with a TypoScript constant.
const.tx_googletagmanager.settings.tagId = GTM-XXX
  1. Optional: Define Data Layer Version with TypoScript
const.tx_googletagmanager.settings.dataLayerVersion = 1
  1. Include GTM in your page template:

Example:

page{
    1 < plugin.tx_googletagmanagerdatalayer_init
     main template
    999 < plugin.tx_googletagmanagerdatalayer
    3000 < plugin.tx_googletagmanager
}
  1. Test if GTM was loaded

You can check in the generated page source if the GTM works. You should see the dataLayer defined, the variables pushed to the dataLayer and towards the end of the page the GTM code:

../_images/GTMCodeBottom.png

You can also check if GTM works as expected using the Google Chrome extension “Tag Assistant (by Google)”.

Pushing variables in the Data Layer

There is a Fluid View Helper to push Data Layer Variables

Example:

{namespace googletagmanager=Tx_GoogleTagManager_ViewHelpers}
<googletagmanager:dataLayer name="tx_googletagmanager_dataLayerVersion" value="{dataLayerVersion}" /></script>

Pushing variables in the Data Layer using a Hook

You can also use a Hook for pushing variables to the Data Layer globally.

Example:

// Class implementing the hook
namespace Acme\Foo;
class Bar implements Aoe\GoogleTagManager\Service\VariableProviderInterface
{
    public function getVariables()
    {
        return array('bar' => 'baz');
    }
}

// Register the hooked class (for example in ext_localconf.php or in a Bootstrap class)
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['google_tag_manager']['variableProviders'][] = Acme\Foo\Bar::class;

Disable Tag Manager

You can disable the Tag Manager with TypoScript

const.tx_googletagmanager.settings.enable = 0