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

Is it possible exclude localhost from making the call to GTM? #106

Open
gugol2 opened this issue Jul 13, 2022 · 4 comments
Open

Is it possible exclude localhost from making the call to GTM? #106

gugol2 opened this issue Jul 13, 2022 · 4 comments

Comments

@gugol2
Copy link

gugol2 commented Jul 13, 2022

I read that this is possible when interacting directly with GTM:

if (admin || localhost) { // disable GA:
  window['ga-disable-UA-XXXXX-Y'] = true; // enter your tracking ID
}

Quoting the docs:

The analytics.js library includes a window property that, when set to true, disables analytics.js from sending data to Google Analytics. When Google Analytics attempts to set a cookie or send data back to the Google Analytics servers, it will check whether this property is set to true. If it is, no action will be taken.

To disable tracking, set the following window property to true:

window['ga-disable-UA-XXXXX-Y'] = true;

Where the value UA-XXXXX-Y corresponds to the property ID on which you would like to disable tracking.

Is this possible using react-gtm?

@gugol2
Copy link
Author

gugol2 commented Jul 13, 2022

At the moment I am solving it like so:

if (!isLocalServer()) {
    optimizelyKey = process.env.REACT_APP_OPTIMIZELY_SDK_KEY!;

    const tagManagerArgs = {
        gtmId: process.env.REACT_APP_GTM_ID as string,
    };

    TagManager.initialize(tagManagerArgs);
}

But I wonder if could be done with an attribute in tagManagerArgs

@gugol2
Copy link
Author

gugol2 commented Jul 13, 2022

Ok, I made a small development...

How could I open a PR to this repo?

@natterstefan
Copy link

@kodiekenta
Copy link

what npm version did you use to install the package

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