thelia / google-tag-manager-module
3.1.19
2024-06-07 14:06 UTC
Requires
- thelia/installer: ~1.1
- thelia/short-code-module: ~2.0
README
此模块旨在使用 Google Tag Manager / Google Analytics 4。
安装
Composer
composer require thelia/google-tag-manager-module:~2.1.0
使用方法
您需要在 thelia 管理面板中配置来自您的 Google 标签管理账户的 id。
它应该看起来像 GTM-XXXX
。
这将生成 head 脚本和 body no-script 标签,并将它们插入到 main.head-top
、main.body-top
、main.javascript-initialization
和 product.bottom
插件中。
如果这些插件在您的模板中不存在,您需要先添加它们。
要跟踪添加到购物车的产品,您需要在“添加到购物车”按钮上实现此 js 事件。
const event = new CustomEvent("addPseToCart", { detail: { pse: pseId, quantity }, }); document.dispatchEvent(event);