Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@devular/gatsby-plugin-plausible

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devular/gatsby-plugin-plausible

A Gatsby plugin for adding Plausible analytics to your Gatsby site

  • 0.1.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-68.75%
Maintainers
2
Weekly downloads
 
Created
Source

@devular/gatsby-plugin-plausible

This plugin was forked from pixelplicity/gatsby-plugin-plausible to support Plausible's proxying configuration.

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 @devular.gatsby-plugin-plausible

    npm install --save @devular/gatsby-plugin-plausible

  2. Add plugin to gatsby-config.js

    // In your gatsby-config.js
    module.exports = {
      plugins: [
        // The only required option is the domain
        {
          resolve: `@devular/gatsby-plugin-plausible`,
          options: {
            domain: `your-site.com`,
            proxyScript: `/sub-directory/script.js`,
            proxyApi: `/sub-directory/api/event`,
          },
        },
      ],
    };
    

Gatsby Recipe

This will install @devular/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/devular/gatsby-plugin-plausible/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

OptionExplanation
domainThe domain configured in Plausible (required)
proxyScriptA script location for a proxy configuration
proxyApiAn collection endpoint for aproxy configurations
excludePathsArray of pathnames where page views will not be sent

_NOTE: You can read more about proxying Plausible here

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 | Devular

Forked from: https://github.com/pixelplicity/gatsby-plugin-plausible with MIT

Keywords

FAQs

Package last updated on 15 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc