Skip to content

Google Analytics plugin should have configurable delay before sending Page View #15504

@Simon-Tang

Description

@Simon-Tang

Summary

To build on the fix for #9139 in #10917, we need to support an optional configurable delay before invoking sendPageView for sites that have custom page transitions. (An example plugin: gatsby-plugin-transition-link).

I can probably make this change in the code, but I wanted to see if anyone else had thoughts on this (e.g. the naming of the option).

Basic example

In gatsby-config.js:

{
  resolve: 'gatsby-plugin-google-analytics`,
  options: {
    pageViewDelay: 250,
  }
},

Motivation

With page transitions, such as when using the plugin linked above, the next route can be mounted after an arbitrary delay, so the current requestAnimationFrame/setTimeout in onRouteUpdate will need to be replaced with a user-configured delay in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions