thelia/google-tag-manager-module

Installs: 1 895

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 6

Forks: 3

Open Issues: 0

Type:thelia-module

3.1.10 2024-02-14 09:21 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 looks 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);