Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to setup properly react-gtm-module #85

Open
vinibispo opened this issue Apr 22, 2021 · 3 comments
Open

How to setup properly react-gtm-module #85

vinibispo opened this issue Apr 22, 2021 · 3 comments

Comments

@vinibispo
Copy link

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

@ghost
Copy link

ghost commented Aug 18, 2021

I also have the same question, is there any guides or examples of real world scenario.

@JMarchetto
Copy link

JMarchetto commented Aug 19, 2021

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);

@Hamdan85
Copy link

Hamdan85 commented May 4, 2022

@JMarchetto but do you know how to add environments to it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants