Coder Social home page Coder Social logo

Comments (7)

noofreuuuh avatar noofreuuuh commented on August 29, 2024 2

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

from ga-4-react.

pedram6195 avatar pedram6195 commented on August 29, 2024

I have the same problem, same error :(

from ga-4-react.

unrealmanu avatar unrealmanu commented on August 29, 2024

do you only use adblocker? or even an antivirus?

from ga-4-react.

pedram6195 avatar pedram6195 commented on August 29, 2024

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

from ga-4-react.

dmathijs avatar dmathijs commented on August 29, 2024

do you only use adblocker? or even an antivirus?

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

from ga-4-react.

OssiPesonen avatar OssiPesonen commented on August 29, 2024

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.

from ga-4-react.

Jodebu avatar Jodebu commented on August 29, 2024

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

from ga-4-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.