heimrichhannot / contao-google-tag-manager-bundle
此插件为Contao CMS提供Google Tag Manager功能。
1.2.0
2022-10-11 09:03 UTC
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
设置
-
使用composer或contao管理器安装
composer require heimrichhannot/contao-google-tag-manager-bundle
-
更新您的数据库
-
调整您的fe_page模板
- 将
<?= $this->googleTagManagerHead ?>
添加到您的头部部分 - 将
<?= $this->googleTagManagerBody ?>
添加到body结束标签之前
- 将
高级使用
向页面添加数据层变量
System::getContainer()->get('huh.google_tag_manager.data_layer')->setContent(['key' => 'value']);
添加带有数据层事件处理器的a标签
System::getContainer()->get('huh.google_tag_manager.tag_manager')->getLink(class, link, linkText, ['event': 'button1-click'])
这将输出: <a href="link" class="class" onclick="dataLayer.push({'event': 'button1-click'});">linkText</a>