Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: gatsby-plugin-google-analytics is getting an undefined pathname #1317

Closed
camsjams opened this issue Jun 30, 2017 · 4 comments
Closed

BUG: gatsby-plugin-google-analytics is getting an undefined pathname #1317

camsjams opened this issue Jun 30, 2017 · 4 comments

Comments

@camsjams
Copy link
Contributor

Currently the code does this:

exports.onRouteUpdate = function(location) {
  // Don't track while developing.
  if (process.env.NODE_ENV === `production`) {
    ga(`set`, `page`, location.pathname)
    ga(`send`, `pageview`)
  }
}

But it appears as though the parameter called location is structured like so:

{
	location: {
		pathname: '/home',
		search: '',
		hash: '',
		key: 'q8junx'
	},
	action: 'PUSH'
}

The resulting bug is that we get production code doing something like:

 ga('set', 'page', undefined);

Causing the GA metrics to show whatever the first SSR-served landing page to be the page viewed many times over (because page will never change).

Pretty easy change, but I am assuming this must have worked before?

Versions:
node v8.0.0
gatsby@1.0.0-beta.5
gatsby-plugin-google-analytics@1.0.0-beta.1

@KyleAMathews
Copy link
Contributor

Oh wow... yeah the plugin is really outdated :-( the API got updated a while ago https://www.gatsbyjs.org/docs/browser-apis/#onRouteUpdate

@KyleAMathews
Copy link
Contributor

could you submit a quick PR for this? I'm making a new release this afternoon so could get this out then.

@camsjams
Copy link
Contributor Author

Sure thing, though I have found a secondary issue as well, you will see in PR.

@KyleAMathews
Copy link
Contributor

Fixed in #1318

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants