moritzsternemann/vue-plausible
moritzsternemann/vue-plausible has 117 GitHub stars and 8 forks. GitHot measured -1 in 7 days. Last checked 2026-11-10 23:08 UTC. Last push 2022-07-13.
Plausible Analytics Vue.js Plugin and NuxtJS Module
측정된 스타 증가
- in 24h
- 업데이트 지연
- in 7 days
- -1
- in 15 days
- 업데이트 지연
- in 1 month
- 업데이트 지연
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalPlausible Analytics for Vue.js and NuxtJS
Vue.js plugin and NuxtJS module for Plausible Analytics
Installation
Using npm:
npm install vue-plausible
Using yarn:
yarn add vue-plausible
Vue.js Plugin
import Vue from 'vue'
import { VuePlausible } from 'vue-plausible'
Vue.use(VuePlausible, {
// see configuration section
})
To enable automatic page view tracking for SPAs, call the enableAutoPageviews() method.
To enable automatic outbound link tracking, call the enableAutoOutboundTracking() method.
NuxtJS Module
// nuxt.config.js
// optional when using nuxt.config.ts
/// <reference types="vue-plausible" />
export default {
modules: [
'vue-plausible'
]
}
Module Options
Add a plausible section to nuxt.config.js to set the module options:
// nuxt.config.js
export default {
plausible: {
// see configuration section
}
}
Runtime Config
To use dynamic environment variables in production, use publicRuntimeConfig.
Otherwise, the configuration options passed in nuxt.config.js will be read once and bundled during the build only.
See the configuration section for all available options.
// nuxt.config.js
export default {
buildModules: [
'vue-plausible'
],
plausible: { // Use as fallback if no runtime config is available at runtime
domain: process.env.PLAUSIBLE_DOMAIN
},
publicRuntimeConfig: {
plausible: {
domain: process.env.PLAUSIBLE_DOMAIN,
apiHost: process.env.PLAUSIBLE_API_HOST
}
}
}
Usage
vue-plausible is based on the official plausible-tracker package.
Configuration
Configuration options are inherited from plausible-tracker:
| Option | Type | Description | Default |
|---|---|---|---|
| domain | string |
Your site's domain name, as declared by you in Plausible's settings. | location.hostname |
| hashMode | boolean |
Enables tracking based on URL hash changes. | false |
| trackLocalhost | boolean |
Enables tracking on localhost. | false |
| apiHost | string |
Plausible's API host to use. Change this if you are self-hosting. | https://plausible.io |
| enableAutoPageviews | boolean |
Enables automatic pageview tracking in SPAs. Learn more | true |
| enableAutoOutboundTracking | boolean |
Enables automatic outbound link click tracking. Learn more | false |
Integration
The plausible-tracker package provides various methods to track specific events, for example trackPageview() and trackEvent(). You can find all the available methods and options in the plausible-tracker documentation.
The Plausible instance is exposed to your Vue.js or NuxtJS app in the following ways:
Vue.$plausible(Vue.js only)this.$plausibleinside Vue componentscontext.app.$plausibleinside asyncData, fetch, plugins, middleware, nuxtServerInit (NuxtJS only)this.$plausibleinside Vuex stores (NuxtJS only)
Proxying
To use proxying as described in the Plausible 'Using a proxy' documentation, you need to adjust the apiHost configuration option accordingly.
Using vue-plausible only requires to proxy the /api/event endpoint since the frontend code is already bundled from plausible-tracker.
Please note that event endpoint path always ends with /api/event. See the following example:
plausible: {
apiHost: 'https://<yourdomain.com>/stats' // Reports events to https://<yourdomain.com>/stats/api/event
}
Opt out
To exclude yourself from the analytics, plausible-tracker offers an opt-out mechanism that can be activated by setting the localStorage.plausible_ignore value to true.
More information can be found in the Plausible documentation.
Author
I'm Moritz Sternemann, a computer-science student at Technical University of Munich.
- GitHub: @moritzsternemann
- Email: [email protected]
- Twitter: @strnmn
License
This project is available under the MIT license. See the LICENSE file for more information.
관련 프로젝트 살펴보기
Asabeneh/30-Days-Of-Python
30 Days of Python 프로그래밍 챌린지는 Python 프로그래밍 언어를 30일 동안 배우기 위한 단계별 가이드입니다. 이 챌린지는 100일 이상 걸릴 수 있습니다. 자신의 속도에 맞춰 진행하세요. 다음 동영상도 도움이 될 수 있습니다: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw
78,560 스타grafana/grafana
개방적이고 조합 가능한 옵저버빌리티 및 데이터 시각화 플랫폼입니다. Prometheus, Loki, Elasticsearch, InfluxDB, Postgres 등 여러 소스의 메트릭, 로그, 트레이스를 시각화합니다.
77,830 스타redis/redis
실시간 데이터 기반 애플리케이션을 구축하는 개발자에게 Redis는 가장 선호되고, 가장 빠르며, 기능이 가장 풍부한 캐시, 데이터 구조 서버이자 문서 및 벡터 쿼리 엔진입니다.
77,395 스타apache/superset
Apache Superset는 데이터 시각화 및 데이터 탐색 플랫폼입니다.
75,473 스타