Install Simple Analytics with Gatsby edit

Run the following command:

npm install gatsby-plugin-simple-analytics --save-dev

What does it do

It tracks page views with support for pushState navigation. It sends the data to Simple Analytics and it will be available in your dashboard. You need to have a paid subscription for it to work.

How to use

  1. Add our plugin to gatsby-config.js

    plugins: [
      {
        resolve: "gatsby-plugin-simple-analytics",
        options: {
          trackPageViews: true,
        },
      },
    ]
    
  2. If you want to set a custom domain, use this config:

    plugins: [
      {
        resolve: "gatsby-plugin-simple-analytics",
        options: {
          domain: "custom.example.com",
          eventsGlobal: "sa",
          events: true,
          trackPageViews: true,
          ignorePages: ["pathname"],
        },
      },
    ]
    

    Read our docs on the custom domain feature.