Open vinibispo opened 3 years ago
I also have the same question, is there any guides or examples of real world scenario.
Are you trying to push the dataLayer in the initialization itself?
I've been successful pushing the dataLayer by initializing on load, and then calling the dataLayer function as a separate event.
On load:
import TagManager from 'react-gtm-module';
const tagManagerArgs = {
gtmId: 'GTM-xxxxxxx', // required
};
TagManager.initialize(tagManagerArgs);
Trigger the dataLayer while performing a specific action (we assume TagManager has already been initialized):
import TagManager from 'react-gtm-module';
const tagManagerArgs = {
dataLayer: {
event: 'eventName', // event to be picked up by GTM
customValue1: '', // anything you want here
}
}
TagManager.dataLayer(tagManagerArgs);
@JMarchetto but do you know how to add environments to it?
Hi, nice work on react-gtm-module, I'm trying to setup this library on my ecommerce, but I couldn't push my datalayer to tag manager, is there a guide or something else?
Environments:
Node: 12.19.0
React: 17.0.2
React GTM Module: 2.0.11