Skip to content

Commit 74f8b9e

Browse files
authored
Merge pull request #1805 from quarto-dev/plausible-analytics
2 parents 57d7484 + abaa570 commit 74f8b9e

File tree

1 file changed

+65
-2
lines changed

1 file changed

+65
-2
lines changed

docs/websites/website-tools.qmd

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,70 @@ image: false
211211
---
212212
```
213213

214-
## Google Analytics
214+
## Analytics
215+
216+
### Plausible Analytics
217+
218+
[Plausible Analytics](https://plausible.io/) is a lightweight, open-source, and privacy-friendly alternative to Google Analytics. Plausible is designed with privacy as a core principle: it doesn't use cookies, is GDPR compliant by default, and all data is processed anonymously.
219+
220+
To add Plausible Analytics to your Quarto website:
221+
222+
1. Sign up at [plausible.io](https://plausible.io/) and add your website to your account.
223+
2. In your Plausible dashboard, navigate to your site's settings.
224+
3. Go to the "Site Installation" section and click "Review Installation" to get your unique tracking snippet.
225+
4. Copy the complete script snippet provided by Plausible from your dashboard.
226+
5. Add it to your `_quarto.yml` configuration file.
227+
228+
You can provide the Plausible snippet in two ways:
229+
230+
**Option 1: Inline snippet**
231+
232+
Paste the snippet directly in your `_quarto.yml` configuration file under the `plausible-analytics` key. Use the `|` character after the key to preserve line breaks in the snippet:
233+
234+
``` yaml
235+
website:
236+
plausible-analytics: |
237+
<script async src="https://plausible.io/js/pa-XXXXXX.js"></script>
238+
<script>
239+
window.plausible=window.plausible||function(){(plausible.q=plausible.q||[]).push(arguments)},plausible.init=plausible.init||function(i){plausible.o=i||{}};
240+
plausible.init()
241+
</script>
242+
```
243+
244+
**Option 2: File path**
245+
246+
Save the snippet to a file (e.g., `_plausible_snippet.html`) and provide the path:
247+
248+
``` yaml
249+
website:
250+
plausible-analytics:
251+
path: _plausible_snippet.html
252+
```
253+
254+
The script will automatically be included in the `<head>` of every page on your website. **Important:** Make sure to copy and paste the complete snippet exactly as provided by Plausible - the example above shows the typical structure, but your actual snippet will have a unique tracking code instead of `XXXXXX`.
255+
256+
::: {.callout-tip}
257+
The snippet from your Plausible dashboard may include multiple `<script>` tags and initialization code. Copy the entire snippet as-is - don't modify or simplify it. Using the file path option can be useful if you want to keep the snippet separate from your configuration or if you need to update it frequently.
258+
:::
259+
260+
#### Optional Enhanced Measurements
261+
262+
Plausible offers optional enhanced measurements that you can enable directly in your site settings dashboard (such as outbound link tracking, file downloads, etc.). When you enable these features in Plausible, your tracking snippet will be automatically updated in your dashboard. Simply copy the updated snippet and replace it in your `_quarto.yml` configuration.
263+
264+
For more information about available enhanced measurements and configuration options, see the [Plausible script documentation](https://plausible.io/docs/plausible-script).
265+
266+
#### Privacy Benefits
267+
268+
Unlike traditional analytics solutions, Plausible Analytics:
269+
270+
- **Uses no cookies**: Plausible doesn't use cookies or generate any persistent identifiers, so no cookie consent banners are needed
271+
- **Is GDPR compliant**: All visitor data is anonymized and processed in the EU
272+
- **Is lightweight**: The script is under 1 KB, significantly smaller than Google Analytics
273+
- **Has no cross-site tracking**: Plausible doesn't track users across different websites
274+
275+
Because Plausible is privacy-friendly by default, you typically don't need to implement [Cookie Consent] when using it (though you should verify this with your own privacy requirements).
276+
277+
### Google Analytics
215278

216279
You can add [Google Analytics](https://analytics.google.com/) to your website by adding a `google-analytics` key to your `_quarto.yml` file. In its simplest form, you can just pass your Google Analytics tracking Id (e.g. `UA-xxxxxxx`) or Google Tag measurement Id (e.g. `G-xxxxxxx`) like:
217280

@@ -242,7 +305,7 @@ In addition to this basic configuration, you can exercise more fine grained cont
242305

243306
: {tbl-colwidths="[20,80]"}
244307

245-
### Storage
308+
#### Storage
246309

247310
Google Analytics uses cookies to distinguish unique users and sessions. If you choose to use cookies to store this user data, you should consider whether you need to enable [Cookie Consent] in order to permit the viewer to control any tracking that you enable.
248311

0 commit comments

Comments
 (0)