Coder Social home page Coder Social logo

gatsby-plugin-plausible-analytics's Introduction

gatsby-plugin-plausible-analytics

npm package

A Gatsby plugin for adding Plausible analytics to your Gatsby site.

The plugin includes the Plausible tracking script. It supports using a custom domain and excluding specific paths from recording page views.


Install

Manual

  1. Install gatsby-plugin-plausible-analytics

    npm install --save gatsby-plugin-plausible-analytics

  2. Add plugin to gatsby-config.js

    // In your gatsby-config.js
    module.exports = {
      plugins: [
        // The only required option is the domain
        {
          resolve: `gatsby-plugin-plausible-analytics`,
          options: {
            domain: `aquil.io`,
          },
        },
      ],
    };

Gatsby Recipe

This will install gatsby-plugin-plausible-analytics and add a sample configuration.

  1. Upgrade gatsby-cli and gatsby to the latest version:

    npm install -g gatsby-cli@latest npm install gatsby@latest

  2. Run the recipe gatsby recipes https://raw.githubusercontent.com/ressonix/gatsby-plugin-plausible-analytics/master/gatsby-recipe-plausible.mdx

  3. Update gatsby-config.js options.

To read more about recipes check out the announcement.

How to use

NOTE: By default, this plugin only generates output when run in production mode. To test your tracking code, run gatsby build && gatsby serve.

Options

Option Explanation
domain The domain configured in Plausible (required)
customDomain Custom domain (if configured in Plausible's dashboard)
excludePaths Array of pathnames where page views will not be sent
outbound Boolean value. Used for tracking outbound links.

Pageview events

Pageviews are sent automatically when a user changes routes, including the initial load of your site.

Triggering custom events

To track goals and conversions you have to trigger custom events first.

window.plausible('Signup', {
  callback: () => console.info('Sent Signup event'),
});

The event name can be anything. The second argument is an object with options. The only supported option is callback that is called once the event has been sent.

NOTE: Custom events will not show up right away. You have to configure a goal in your Plausible dashboard.

Changelog

See CHANGELOG.md.

License

MIT © Pixelplicity

gatsby-plugin-plausible-analytics's People

Contributors

ccummings avatar foggymtndrifter avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.