Git Product home page Git Product logo

Comments (8)

benjaminhoffman avatar benjaminhoffman commented on August 16, 2024

this is weird. do you have an ad blocker? which browser are you using. how does this work on production, or you only see the issue on dev? when you check for window.analytics in your chrome console, what happens?

please let me know the above, or if the issue is solved, please comment what the fix was. thanks!

from gatsby-plugin-segment-js.

daveyheuser avatar daveyheuser commented on August 16, 2024

I had the same issue, and window.analytics returned undefined for me in the Chrome console. However, this was only on localhost, and it works fine on production.

from gatsby-plugin-segment-js.

benjaminhoffman avatar benjaminhoffman commented on August 16, 2024

what about when you do yarn build ... i assume it works then?

and you've checked incognito browser, with no ad blockers, right?

from gatsby-plugin-segment-js.

peterphan1996 avatar peterphan1996 commented on August 16, 2024

I also had this issue, window.analytics returned undefined, I've tried yarn build but no luck

from gatsby-plugin-segment-js.

geoffgolder-ah avatar geoffgolder-ah commented on August 16, 2024

just in case someone comes across this, it means you probably don't have a DEV key defined. the prod key will only run in production, local host is dev environment.

from gatsby-plugin-segment-js.

alexfornuto avatar alexfornuto commented on August 16, 2024

I hit the same issue, until I wrapped my window.analytics.track in a if (window.analytics) conditional.

It looks to me like the analytics.js script isn't being loaded into the page header. This is true even on production build. When looking at the chrome console (adblocker disabled), I have no window.analytics options available.

from gatsby-plugin-segment-js.

149203 avatar 149203 commented on August 16, 2024

I had this problem because I copied the code snippet from the docs which contains a junk code snippet:

customSnippet: '!function(){var analytics=window.analytics||[];...;analytics.load("${writeKey}");analytics.page();}}();'

I had to remove that. 😦

from gatsby-plugin-segment-js.

Senthil-Sivanath avatar Senthil-Sivanath commented on August 16, 2024

Without a valid env variable, analytics doesn't load; Set NODE_ENV to production or development

export NODE_ENV=production

or

export NODE_ENV=development

from gatsby-plugin-segment-js.

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.