Skip to content

Use Gatsby's Deferred Static Generation (DSG) with Plausible Analytics (or any analytics tool)

Notifications You must be signed in to change notification settings

LekoArts/gatsby-dsg-plausible-analytics

Repository files navigation

Gatsby DSG + Plausible Analytics

Example of using Deferred Static Generation (DSG) for pages in your Gatsby site, depending on which pages are the most visited. The list of most viewed pages is determined by accessing Plausible Analytics.

You can use this example for the analytics tool you use, the general idea & setup will be the same.

Read the full blogpost Using Deferred Static Generation with Analytics Tools to learn more!

General Idea

  1. Create a local plugin to access the needed data from your analytics tool
  2. In this plugin, create GraphQL nodes in the sourceNodes lifecycle
  3. Use the data from your analytics plugin to mark pages in the createPages lifecycle as defer or not

About

Use Gatsby's Deferred Static Generation (DSG) with Plausible Analytics (or any analytics tool)

Resources

Stars

Watchers

Forks