heimrichhannot / contao-google-tag-manager-bundle
This bundle offers google tag manager for the Contao CMS.
Installs: 312
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 6
Forks: 0
Open Issues: 2
Type:contao-bundle
Requires
- php: ^7.1 || ^8.0
- contao/core-bundle: ^4.4
- heimrichhannot/contao-utils-bundle: ^2.0
Requires (Dev)
- contao/manager-plugin: ^2.0
- contao/test-case: ^1.1
- friendsofphp/php-cs-fixer: ^2.2
- php-coveralls/php-coveralls: ^2.0
- php-http/guzzle6-adapter: ^1.1
- php-http/message-factory: ^1.0.2
- phpunit/phpunit: >=6.0 <6.5
- symfony/phpunit-bridge: ^3.2
README
Setup
-
Install with composer or contao manager
composer require heimrichhannot/contao-google-tag-manager-bundle
-
Update your database
-
Adjust your fe_page template
- Add
<?= $this->googleTagManagerHead ?>
to your head section - Add
<?= $this->googleTagManagerBody ?>
to before the body closing tag
- Add
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>