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

'Manual start' fails when a addblocker is installed #14

Open
dmathijs opened this issue Apr 2, 2021 · 7 comments
Open

'Manual start' fails when a addblocker is installed #14

dmathijs opened this issue Apr 2, 2021 · 7 comments
Assignees

Comments

@dmathijs
Copy link

dmathijs commented Apr 2, 2021

Like the title says, trying to access the application that uses manual start with an addblocker activated, I get the following error:

image

I'm also having a hard time configuring my application with the docs, for someone who's not really pro with react there's a lot of context missing in the examples.

@pedram6195
Copy link

I have the same problem, same error :(

@unrealmanu
Copy link
Owner

do you only use adblocker? or even an antivirus?

@unrealmanu unrealmanu self-assigned this Apr 6, 2021
@pedram6195
Copy link

I have not any adblockers or antivirus on my system. I have windows 7 and I use chrome last version.
but...
I disabled all my chrome's addons and then enabled them again, now it works without error. thanks

@dmathijs
Copy link
Author

dmathijs commented Apr 6, 2021

do you only use adblocker? or even an antivirus?

It's only adblocker, disabling it fixes the issue.

@OssiPesonen
Copy link

OssiPesonen commented Apr 22, 2021

We are suffering from a generic issue like this as well, and getting repeated errors in Sentry.

GA4React intialization failed
{"type":"error"}

There's basically nothing more. Sometimes we get timeout errors. Users seem to enter our application from all directions. Most errors tend to be from Windows or Mobile (Android) devices. Browsers are mostly only Chrome v. 69 and above, but also WebView, Opera Mobile, iOS safari etc.

This error might not even be related to this library since we had errors before installing ga-4-react. There seems to be some type of TypeError in gtag/js which gets triggered by random users.

TypeError
Illegal invocation

On line 495:

{snip} ))}}},vq=function(a,b,c){var d=a+"?"+b;c?dd.sendBeacon&&dd.sendBeacon(d,c):rd(d)};var Aq=window,Bq=document,Cq=function(a){var b=Aq._gaUserP {snip}

The script is initialized in index.js when using create-react-app. Manual start, essentially.

We haven't found anything on our searches as to what might cause this issue. I tried replicating this with AdBlocker plus but Analytics works just fine. Can't pinpoint the cause. Any help would be appreciated. If this is indeed an AdBlocker issue I'd like for someone to replicate this and maybe throw in a solution as to how we can detect adblock users on our site before initializing analytics so we don't have Sentry spam us with errors.

@noofreuuuh
Copy link

noofreuuuh commented May 22, 2021

I reproduced also the issue with Ghostery.
To not have an UI issue due to that, i added a try catch around ga4react.initialize();

try {
    await ga4react.initialize();
} catch (e) {
    console.error("Addblock is activated");
}

@Jodebu
Copy link

Jodebu commented Aug 17, 2021

I solved this issue in a similar way to @noofreuuuh, but on render:

ga4react.initialize()
  .then(() => config.GA_TRACKING_BLOCKED = false)
  .catch(() => config.GA_TRACKING_BLOCKED = true)
  // eslint-disable-next-line react/no-render-return-value
  .finally(() => ReactDOM.render(<App />, document.getElementById('root')));

I use the config variable later to decide if I can set up the tags:

const ga = useGA4React();
if (!config.GA_TRACKING_BLOCKED && !!ga) {
  history.listen(location => {
    ga.pageview(location.pathname);
    ga.gtag('event', 'pageview', 'path');
  });
}

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

6 participants