thelia / google-tag-manager-module
Installs: 2 442
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 6
Forks: 8
Open Issues: 0
Type:thelia-module
Requires
- thelia/installer: ~1.1
- thelia/short-code-module: ~2.0
This package is auto-updated.
Last update: 2024-11-07 14:52:54 UTC
README
This module is made to use the Google Tag Manager / Google Analytics 4.
Installation
Composer
composer require thelia/google-tag-manager-module:~2.1.0
Usage
You need to configure the id from your Google tag manager account in the thelia administration panel.
It should look like GTM-XXXX
.
This will generate both the head script and the body no-script tags and insert them in the main.head-top
,
in the main.body-top
, in the main.javascript-initialization
and in the product.bottom
hooks.
If these hooks are not present in your template, you'll need to add them beforehand.
To track products added to the cart, you need to implement this js event on the "Add to cart" buttons.
const event = new CustomEvent("addPseToCart", { detail: { pse: pseId, quantity }, }); document.dispatchEvent(event);