@aaromp/gatsby-plugin-plausible 中文文档教程

发布于 4年前 浏览 21 项目主页 更新于 3年前

gatsby-plugin-plausible

npm 包可维护性Dependabot

一个用于添加 对您的 Gatsby 网站进行合理的分析。

该插件包括 Plausible 跟踪脚本。 它支持使用自定义域并从记录页面视图中排除特定路径。


Install

Manual

  1. 安装 gatsby-plugin-plausible

    npm install --save gatsby-plugin-plausible

  2. 将插件添加到 gatsby-config.js

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

Gatsby Recipe

这将安装 gatsby-plugin-plausible 并添加示例配置。

  1. 将 gatsby-cli 和 gatsby 升级到最新版本:

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

  2. 运行配方 gatsby 食谱 https://raw.githubusercontent.com/Aquilio/gatsby-plugin-plausible/master/gatsby-recipe-plausible.mdx

  3. 更新 gatsby-config.js < href="#options">选项。

要阅读有关食谱的更多信息,请查看公告

How to use

注意:默认情况下,此插件仅在生产模式下运行时生成输出。 要测试您的跟踪代码,请运行 gatsby build && 盖茨比发球

Options

OptionExplanation
domainThe domain configured in Plausible (required)
customDomainCustom domain (if configured in Plausible's dashboard)
excludePathsArray of pathnames where page views will not be sent

Pageview events

当用户更改路线(包括您网站的初始加载)时,会自动发送综合浏览量。

Triggering custom events

要跟踪目标和转化,您必须先触发自定义事件。

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

事件名称可以是任何东西。 第二个参数是一个带有选项的对象。 唯一支持的选项是 callback,它在事件发送后被调用。

注意:自定义事件不会立即显示。 您必须在合理的仪表板中配置一个目标

Changelog

请参阅 CHANGELOG.md

License

麻省理工学院 © Aquil。 io

gatsby-plugin-plausible

npm packageMaintainabilityDependabot

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

    npm install --save 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: `gatsby-plugin-plausible`,
         options: {
           domain: `aquil.io`,
         },
       },
     ],
   };

Gatsby Recipe

This will install 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/Aquilio/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)
customDomainCustom domain (if configured in Plausible's dashboard)
excludePathsArray of pathnames where page views will not be sent

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 © Aquil.io

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文