react-gtm
react-gtm copied to clipboard
Is it possible exclude localhost from making the call to GTM?
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?
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
Ok, I made a small development...
How could I open a PR to this repo?
Hi @gugol2,
here is a step by step guide: https://www.digitalocean.com/community/tutorials/how-to-create-a-pull-request-on-github.
what npm version did you use to install the package