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

[gatsby-plugin-react-helmet] and [gatsby-plugin-google-analytics] don't play well with Title changes #2478

Closed
jbrantly opened this issue Oct 16, 2017 · 5 comments

Comments

@jbrantly
Copy link

When using React Helmet and the Google Analytics plugin together, it seems that the route change handler causing GA to fire occurs before React Helmet has a chance to update the <title>. This results in GA data often having the previous page title for any given URL.

This can be seen in the existing gatsbyjs.org site by navigating to the homepage, then to the "Community" page, and back and forth. The Community page has a different title than the other pages, and if you check the Network tab for the GA tracker you can see that the title is always the previous page.

@KyleAMathews
Copy link
Contributor

Yeah that makes sense!

Perhaps we just wrap the GA update in a setTimeout to let react helmet finish before running?

How's that sound? Want to put together a PR?

@tylercrosse
Copy link

I haven't dug too deeply into this but using nfl's react metrics might be an option

@LekoArts
Copy link
Contributor

LekoArts commented Oct 23, 2017

@KyleAMathews Would also be interested in a solution. So you propose to set a timeout here?
https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-google-analytics/src/gatsby-browser.js

@KyleAMathews
Copy link
Contributor

@LekoArts yeah exactly. Just set a timeout of 0 and that should be enough to make GA wait for the title update to finish.

@Chuloo
Copy link
Contributor

Chuloo commented Aug 29, 2018

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues as many of them have already been resolved with the latest updates or explained in a previous issue.

Feel free to open a new one if you still experience this problem or a similar one! 👍

@Chuloo Chuloo closed this as completed Aug 29, 2018
wardpeet added a commit that referenced this issue Feb 15, 2019
There is still a problem with title and path not being correct while navigating across a page.

As referenced in: #9139
Solution made in:  #2478 and #3362

For some reason the previous solution is being overwritten

Co-authored-by: Ward Peeters <ward@coding-tech.com>
pragmaticpat pushed a commit to pragmaticpat/gatsby that referenced this issue Apr 28, 2022
…byjs#10917)

There is still a problem with title and path not being correct while navigating across a page.

As referenced in: gatsbyjs#9139
Solution made in:  gatsbyjs#2478 and gatsbyjs#3362

For some reason the previous solution is being overwritten

Co-authored-by: Ward Peeters <ward@coding-tech.com>
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

5 participants