Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Detect when Google Analytics is blocked. #449

@EliteMasterEric

Description

@EliteMasterEric

Software addons such as AdBlock Plus, uBlock Origin, Ghostery, Brave browser, and more will all prevent Google Analytics from loading by blocking the web request. Extenuating circumstances such as server issues can also prevent connection to Google Analytics.

In this scenario, there should be a convenient function that reliably determines if the Google Analytics script has loaded and the server is accessible.

Something like the following:

// If not using AdBlocker:
ReactGA.initialize('UA-000000-01');

ReactGA.hasLoaded(); // Returns 'true'
// If using an AdBlocker, or if the Google Analytics server is otherwise unaccessible:
ReactGA.initialize('UA-000000-02');

ReactGA.hasLoaded(); // Returns 'false'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions