Git Product home page Git Product logo

gatsby-plugin-segment-js's People

Contributors

ahnkee avatar arthurdenner avatar benjaminhoffman avatar coreyward avatar i8ramin avatar kilian avatar lekoarts avatar marclar avatar mariusbutuc avatar mirshko avatar newhouse avatar seankovacs avatar sreucherand avatar thtmnisamnstr avatar tompridham avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gatsby-plugin-segment-js's Issues

Not Compatible with Gatsby 5

Hey!

When I gatsby develop locally I get this warning:

warn Plugin gatsby-plugin-segment-js is not compatible with your gatsby version 5.0.0 - It requires gatsby@^2 || ^3 || ^4

It seems to be working OK for me but I use it just to add the script, so for me it's safe to just to ignore it. I suppose there'd need to be more tests done to check more complicated functionality before declaring that it's fully working with Gatsby 5.

Thank you for your time πŸ™‡

Delayed loading issue

Page load events are not being sent after enabling delayed loading on Gatsby.

	{
			resolve: `gatsby-plugin-segment-js`,
			options: {
				prodKey: `***************`,
				trackPage: true,
				delayLoad: true,
				delayLoadTime: 1000
			}
		}

"gatsby": "^2.13.31"
"gatsby-plugin-segment-js": "^3.1.0"

Thanks!

trackPage option should track route changes

Is there a reason why the trackPage option only calls analtyics.page() once on initial render, and not on every route change? Seems kinda redundant, and should definitely be documented if nothing else.

`title` reflects the previous page

Thanks for a great plugin!

I got it working but noticed in my segment dashboard that the title property always reflects the previous page instead of the one being reported in the pageview.

For example, navigating to /contact from /download shows up as:

analytics.page({
  path: '/contact',
  referrer: '',
  search: '',
  title: 'Download Qri',
  url: 'http://localhost:9000/contact'
});

I'm wondering if anyone has encountered this before or has an idea what could be going wrong.

I have delayLoad set to true and delayLoadTime set to 1000

Plugin is empty

Looks like this plugin is missing the gatsby-ssr.js file when pulling down via NPM / Yarn

Change functionality of delayLoad?

Out of curiosity, was there a particular reason scroll and route changes were chosen as triggers for script load? My usecase needs to delay the load of the script for performance reasons, but an idle pageview is still valuable to us to accurately assess bounce rates.

Is it worth creating an option to listen to load instead of scroll? If so, I'm happy to submit a PR if the community thinks it would be useful.

No automatic Identify User calls for anonymous visitors

I am not seeing any identify calls in the Segment debugger for anonymous users.
It's my understanding that anonymous users are tracked automatically (Note from Segment):

Note: You won’t need to call identify for anonymous visitors to your site. We’ll automatically assign them an anonymousId, so just calling page and track will still work just fine without identify.

Is anyone else experiencing this issue? Is this an issue with Gatsby/SSR and Segment?

Additional info:

  • I have trackPage set to true and it is working
  • All the Track events I have added to my Gatsby site are appearing in Segment's debugger
  • I don't have any identify calls on my site since I do not register/login users, so I rely on the automatic tracking of anonymous users.

Accessing analytics.track

Analytics is not found when trying to trigger analytics.track from a page. Do you have example code of this working?

Not receiving tracking events

Hi, I'm not receiving any tracking events.

I have no problem tracking with the deprecated package (gatsby-plugin-segment) but after uninstalling it and installing this package no tracking events come through.

Any help would be much appreciated.

gatsby-config.js below:

module.exports = {
  siteMetadata: {
    // ...
  },
  plugins: [
    // ...
    {
      resolve: `gatsby-plugin-segment-js`,
      options: {
        prodKey: `<PROD_WRITE_KEY>`,
        devKey: `<OTHER_WRITE_KEY>`,
      },
    },
  ],
}

Working correctly with deprecated library, for reference:

module.exports = {
  siteMetadata: {
    // ...
  },
  plugins: [
    // ...
    {
      resolve: `gatsby-plugin-segment`,
      options: {
        writeKey: `<PROD_WRITE_KEY>`,
      },
    },
  ],
}

Double page tracking via gatsby-ssr.js and gatsby-browser .js

Enabling trackPage option makes these lines to get run one after all, which ends in duplicate page tracking:

First this from gatsby-ssr.js:

if (trackPage) {
snippet += 'analytics.page();'
}

or this if delayLoad is enabled:

window.analytics.load('${writeKey}');${ trackPage ? 'window.analytics.page();' : ''}

and, then, this other from gatsby-browser.js:

window.analytics && window.analytics.page(document.title);

In addition, gatsby-ssr and gatsby-broswer calls to page differ. SSR verison does not pass anything and browser passes the document.title as param.

Cannot read property 'track' of undefined

Hello,

I've followed the instructions on the Readme.

  • Added plugin to gatsby-config
{
	resolve: 'gatsby-plugin-segment-js',
	options: {
		prodKey: 'KEY_HERE',
	},
}
  • Then, tracking an event:
window.analytics.track('test');

On development mode, I get Cannot read property 'track' of undefined.

Am I doing something wrong?

I know I can check if window.analytics exists, but the docs imply that this plugin was handling that?

page tracking not fired on initial page load

After experimenting a bit with this plugin with trackPage: true, I saw that page tracking events only happened when navigating within the app using client-side routing. The initial load of a page didn't show up in the segment debugger.

I experimented by trying to add window.analytics && window.analytics.page(); to some of the SSR API functions in gatsby, but wasn't able to get it working.

Am I missing something, or is the page tracking only triggered when client-side route changes?

Unexpected identifier 'window'

Hi! I have a problem with the plugin version 4.0.1.

In the console, I get the error: Uncaught SyntaxError: Unexpected identifier 'window'

Check image
image

`page()` does not capture correct path if site uses `canonical` link tag

my site uses a link rel="canonical" tag to support various crawlers/social share/etc. I do this with react-helmet.

calling analytics.page() on onRouteUpdated doesn't work in this case, because this fires before the react component that renders the meta tag is re-rendered.

so at the time when analytics.js tries to figure out what hte current page path is, it looks at the canonical tag and sees <link data-react-helmet="true" rel="canonical" href="https://todayilearned.io/">.

so page() path is set to /.

ScreenCapture at Thu Mar 14 23:56:00 PDT 2019

ScreenCapture at Thu Mar 14 23:56:38 PDT 2019

the fix could be to use the location.pathname passed to the onRouteUpdate hook, as it's the correct route at that point:

ScreenCapture at Thu Mar 14 23:57:15 PDT 2019

segment.js does allow passing in the path manually: https://segment.com/docs/sources/website/analytics.js/#default-properties

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.