Giter VIP home page Giter VIP logo

Comments (2)

DavidWells avatar DavidWells commented on May 23, 2024

I don't see window.Analytics on the global window on https://lovemyvoice.app/

For the gatsby route plugin to work you need to set analytics to the window.

/* analytics.js */
import Analytics from 'analytics'
import segmentPlugin from 'analytics-plugin-segment'
import gtagManagerPlugin from 'analytics-plugin-google-tag-manager'
// ... whatever analytics provider you use

const analytics = Analytics({
  plugins: [
    gtagManagerPlugin({
      containerId: 'GTM-XYZ'
    }),
    segmentPlugin({
      writeKey: '123567',
    }),
  ]
})

// Set to global so analytics plugin will work with Gatsby
if (typeof window !== 'undefined') {
  window.Analytics = analytics
}

// Set to window.
window.Analytics = analytics

https://github.com/DavidWells/analytics/blob/master/packages/gatsby-plugin-analytics/gatsby-browser.js#L6

Alternatively, you can use a standalone routeChange utility https://github.com/DavidWells/analytics/blob/master/examples/react/src/index.js#L12 to avoid exposing to the global window

from analytics.

danielkcz avatar danielkcz commented on May 23, 2024

Sorry, I needed to deploy some working solution there. Ended up with a combination of gatsby-plugin-google-analytics along with a direct Firebase Analytics module (still deciding which one to keep). Both of those are working correctly, but the analytics module wasn't for some reason.

I guess I will close it here now. Thanks for the reply.

from analytics.

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.