Coder Social home page Coder Social logo

gatsby-plugin-parsely-analytics's People

Contributors

dependabot[bot] avatar hbbtstar avatar kbourgoin avatar mraakashshah avatar msukmanowsky avatar wattenberger avatar

Watchers

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

gatsby-plugin-parsely-analytics's Issues

Pageviews associated with previous page's metadata

I have noticed behavior where the metadata sent on a pageview event is incorrect. Instead, the metadata is from the previous page.

Effectively, the plug-in is sending a pageview event for before the tracker can execute metadata extraction. In cases of dynamic page refreshes, the metadata that's already there (the previous page's metadata) is sent in the pageview event. Gatsby i
(shout out Josh R for investigating and identifying the failure point when I was at wit's end.)

Luckily, GA has the same issues. I've adapted their solution to our case.

I do not have write permissions for this repo, so I am replicating the work here.

Git hash to cherry pick: git cherry-pick 6529efc

gatsby-browser.js

  [...]
  const params [...]
  [...]

  // wrap in a timeout to give metadata extraction and react-helmet time to execute
  // adapted from gatsby-plugin-google-analytics
  // https://github.com/gatsbyjs/gatsby/blob/2753c4d75e909699348c4f871f0dbfaee7db37ab/packages/gatsby-plugin-google-analytics/src/gatsby-browser.js#L13
  const sendPageView = () => {
    if (options.parselyTrackPageViewExists) {
      window.PARSELY.beacon.trackPageView(params);
    } else {
      window.PARSELY.pageviewQueue.push(params);
    }
  };

  // Minimum delay for reactHelmet's requestAnimationFrame
  setTimeout(sendPageView, 32);

  return null;
};
// EOF

Aside: once this is fixed I'll add Parse.ly to the Gatsby Analytics providers page.

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.