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

React-native support #43

Open
polcats opened this issue May 24, 2023 · 3 comments
Open

React-native support #43

polcats opened this issue May 24, 2023 · 3 comments

Comments

@polcats
Copy link

polcats commented May 24, 2023

Is this web-only? Or would it work in react-native as well?

@AdamGerthel
Copy link

I'm wondering the same thing. Looking at the source, it seems to be limited to web since it's using both document and window:

react-ga4/src/ga4.js

Lines 90 to 105 in d0b14c2

if (!this._hasLoadedGA) {
// Global Site Tag (gtag.js) - Google Analytics
const script = document.createElement("script");
script.async = true;
script.src = `${gtagUrl}?id=${GA_MEASUREMENT_ID}`;
if (nonce) {
script.setAttribute("nonce", nonce);
}
document.body.appendChild(script);
window.dataLayer = window.dataLayer || [];
window.gtag = function gtag() {
window.dataLayer.push(arguments);
};
this._hasLoadedGA = true;

@polcats
Copy link
Author

polcats commented Jun 8, 2023

I'm wondering the same thing. Looking at the source, it seems to be limited to web since it's using both document and window:

react-ga4/src/ga4.js

Lines 90 to 105 in d0b14c2

if (!this._hasLoadedGA) {
// Global Site Tag (gtag.js) - Google Analytics
const script = document.createElement("script");
script.async = true;
script.src = `${gtagUrl}?id=${GA_MEASUREMENT_ID}`;
if (nonce) {
script.setAttribute("nonce", nonce);
}
document.body.appendChild(script);
window.dataLayer = window.dataLayer || [];
window.gtag = function gtag() {
window.dataLayer.push(arguments);
};
this._hasLoadedGA = true;

Yea, we ended up using react-native-firebase/analytics for mobile.

@AdamGerthel
Copy link

Yea, we ended up using react-native-firebase/analytics for mobile.

Same

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

2 participants