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

feat(gatsby-plugin-google-gtag): Add delayOnRouteUpdate option #37017

Conversation

Simon-Tang
Copy link
Contributor

@Simon-Tang Simon-Tang commented Nov 11, 2022

Description

This adds a new delayOnRouteUpdate option to gatsby-plugin-google-gtag, which is needed for correct pageview events when page transitions are in use. (e.g. with https://www.gatsbyjs.com/plugins/gatsby-plugin-transition-link/). Without this parameter, for sites that have route change animations, pageview events are logged based on the old page instead of the new page.

This ports over a change that I made to the previous (now-deprecated) gatsby-plugin-google-analytics: #15610. However, I've renamed the option to delayOnRouteUpdate which I think is more descriptive.

Documentation

Updated the README for this plugin, similarly to #15610.

Related Issues

Fixes #15504

@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Nov 11, 2022
@Simon-Tang
Copy link
Contributor Author

I'm not really sure about what's causing this test failure. I don't think this code change (extra setTimeout) should be breaking anything, since the function being called just invokes the Google pageview event, and the syntax is correct as far as I can tell.

@Simon-Tang Simon-Tang force-pushed the feat/gatsby-plugin-google-gtag-delayOnRouteUpdate branch from 1749cdc to 2de4641 Compare November 11, 2022 19:56
@Simon-Tang
Copy link
Contributor Author

I think these are probably just flaky tests, reran and the original failure passed. These changes were already in use for the last few years in the old plugin, though.

@LekoArts LekoArts added topic: plugins-analytics Various analytics plugins like gatsby-plugin-google-analytics and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Nov 16, 2022
@Simon-Tang Simon-Tang force-pushed the feat/gatsby-plugin-google-gtag-delayOnRouteUpdate branch from 2de4641 to 7ec55ed Compare November 17, 2022 01:44
@LekoArts LekoArts changed the title feat: add delayOnRouteUpdate option to gatsby-plugin-google-gtag feat(gatsby-plugin-google-gtag): Add delayOnRouteUpdate option Nov 17, 2022
@LekoArts LekoArts merged commit c132f2d into gatsbyjs:master Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: plugins-analytics Various analytics plugins like gatsby-plugin-google-analytics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Google Analytics plugin should have configurable delay before sending Page View
2 participants