npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dnwjn/gatsby-plugin-plausible

v0.0.10

Published

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

Downloads

232

Readme

gatsby-plugin-plausible

npm package

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

The plugin includes the Plausible tracking script for a configured domain. It also supports:

  • using a custom domain (if you are not using the cloud version of Plausible),
  • using a custom script (if you are not using the default script.js), and
  • excluding specific paths from recording page views.

[!NOTE] This is a fork of the original gatsby-plugin-plausible plugin, which is no longer maintained (last activity in 2020).


Table of contents

Install

Manual

  1. Install the plugin:

    npm install --save @dnwjn/gatsby-plugin-plausible
  2. Add the plugin to gatsby-config.js:

    // gatsby-config.js
    module.exports = {
      plugins: [
        {
          resolve: '@dnwjn/gatsby-plugin-plausible',
          options: {
            domain: 'your-gatsby-site.tld',
            plausibleDomain: 'your-plausible-instance.tld',
            plausibleScript: 'script.outbound-links.js',
            excludePaths: ['/exclude-path'],
          },
        },
      ],
    };

Gatsby Recipe

This will install @dnwjn/gatsby-plugin-plausible 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/dnwjn/gatsby-plugin-plausible/master/gatsby-recipe-plausible.mdx
  3. Edit gatsby-config.js and set the options accordingly.

To read more about recipes, check out the announcement.

How to use

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

Options

| Option | Explanation | | -------------------------- | ------------------------------------------------------------ | | domain (required) | The domain configured in Plausible. | | plausibleDomain | Custom domain (if not using the cloud version of Plausible). | | plausibleScript | Custom script (if not using the default script.js). | | excludePaths | Array of paths that should not trigger page views. |

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. You can do that as follows:

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] You have to configure a goal in your Plausible dashboard before custom events will show up.

Changelog

For an overview of changes, see CHANGELOG.md.

License

This project is licensed under the MIT License.

Original work copyright (c) 2020-2024 Pixelplicity

Modified work copyright (c) 2024 dnwjn