thelia/google-tag-manager-module

安装数: 2,353

依赖项: 0

建议者: 0

安全性: 0

星标: 1

关注者: 6

分支: 8

开放问题: 0

类型:thelia-module

3.1.19 2024-06-07 14:06 UTC

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-topmain.body-topmain.javascript-initializationproduct.bottom 插件中。
如果这些插件在您的模板中不存在,您需要先添加它们。

要跟踪添加到购物车的产品,您需要在“添加到购物车”按钮上实现此 js 事件。

const event = new CustomEvent("addPseToCart", {
    detail: {
          pse: pseId,
          quantity
    },
 });
 document.dispatchEvent(event);