heimrichhannot/contao-google-tag-manager-bundle

This bundle offers google tag manager for the Contao CMS.

1.2.0 2022-10-11 09:03 UTC

This package is auto-updated.

Last update: 2024-10-08 10:35:43 UTC


README

Setup

  1. Install with composer or contao manager

     composer require heimrichhannot/contao-google-tag-manager-bundle
    
  2. Update your database

  3. Adjust your fe_page template

    • Add <?= $this->googleTagManagerHead ?> to your head section
    • Add <?= $this->googleTagManagerBody ?> to before the body closing tag

Advanced usage

add data layer variables to a page

System::getContainer()->get('huh.google_tag_manager.data_layer')->setContent(['key' => 'value']);

add an a tag with data layer event handler

System::getContainer()->get('huh.google_tag_manager.tag_manager')->getLink(class, link, linkText, ['event': 'button1-click'])

This will output: <a href="link" class="class" onclick="dataLayer.push({'event': 'button1-click'});">linkText</a>