Plausible Analytics
Plausible Analytics is a simple, privacy-friendly
Google Analytics alternative. With loadScript: true the destination loads
Plausible's manual script (script.manual.js) for your domain; without a
domain it fails with a config error, because Plausible counts each event
for that domain. It installs the plausible queue function and sends each
event as plausible(name, data).
Plausible is a web destination in the walkerOS flow:
Installation
npm install @walkeros/collector @walkeros/web-destination-plausible- Integrated
- Bundled
import { startFlow } from '@walkeros/collector';
import destinationPlausible from '@walkeros/web-destination-plausible';
await startFlow({
destinations: {
plausible: {
code: destinationPlausible,
config: {
loadScript: true,
settings: {
domain: 'example.com',
},
},
},
},
});
A complete flow.json with this destination:
{
"version": 4,
"flows": {
"default": {
"config": {
"platform": "web"
},
"destinations": {
"plausible": {
"package": "@walkeros/web-destination-plausible",
"config": {
"loadScript": true,
"settings": {
"domain": "example.com"
}
}
}
}
}
}
}The quickstart above sets no consent, so the Plausible script loads and receives
every event without analytics consent, and a revocation changes nothing. Add
consent: { analytics: true } to config, next to settings, before you go
live (see gate a destination).
Plausible counts a page view only for an event named pageview, and the manual
script records none by itself: add
"mapping": { "page": { "view": { "name": "pageview" } } } to the destination's
config. Without it, a walkerOS page view reaches Plausible as a custom event
named page view.
Configuration
This destination uses the standard destination config wrapper (consent, data, env, id, ...). For the shared fields see destination configuration. Package-specific fields live under config.settings and are listed below.
Settings
| Property | Type | Description | More |
|---|---|---|---|
domain | string | The domain of your site as registered in Plausible (like example.com). Required when loadScript is true |
Mapping
This package does not define custom rule-level settings. For the standard rule fields (consent, condition, data, batch, name, policy) see mapping.
Examples
Custom event
A generic entity action fires a Plausible custom event with mapped scalar props.
{
"name": "entity action",
"data": {
"string": "foo",
"number": 1,
"boolean": true,
"array": [
0,
"text",
false
]
},
"context": {
"dev": [
"test",
1
]
},
"globals": {
"lang": "elb"
},
"custom": {
"completely": "random"
},
"user": {
"id": "us3r",
"device": "c00k13",
"session": "s3ss10n"
},
"nested": [
{
"entity": "child",
"data": {
"is": "subordinated"
}
}
],
"consent": {
"functional": true
},
"id": "a4d76856b028d464",
"trigger": "test",
"entity": "entity",
"action": "action",
"timestamp": 1700000201000,
"timing": 3.14,
"source": {
"count": 1,
"trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
"type": "collector",
"schema": "4"
}
}{
"name": "Custom Event",
"data": {
"map": {
"props": {
"map": {
"string": "data.string",
"number": "data.number",
"boolean": "data.boolean"
}
}
}
}
}window.plausible("Custom Event", {
"props": {
"string": "foo",
"number": 1,
"boolean": true
}
})Initialization
Destination bootstrap loads the Plausible script for the configured domain and installs the queue.
{
"loadScript": true,
"settings": {
"domain": "example.com"
}
}script.appendChild({
"src": "https://plausible.io/js/script.manual.js",
"domain": "example.com"
})Purchase
A completed order fires a Plausible purchase event with revenue currency and amount.
{
"name": "order complete",
"data": {
"id": "0rd3r1d",
"currency": "EUR",
"value": 462,
"tax": 73.76,
"shipping": 5.22,
"total": 467.22
},
"context": {
"shopping": [
"complete",
0
]
},
"globals": {
"pagegroup": "shop"
},
"custom": {
"completely": "random"
},
"user": {
"id": "us3r",
"device": "c00k13",
"session": "s3ss10n"
},
"nested": [
{
"entity": "product",
"data": {
"id": "ers",
"name": "Everyday Ruck Snack",
"color": "black",
"size": "l",
"price": 420
},
"context": {
"shopping": [
"complete",
0
]
},
"nested": []
},
{
"entity": "product",
"data": {
"id": "cc",
"name": "Cool Cap",
"size": "one size",
"price": 42
},
"context": {
"shopping": [
"complete",
0
]
},
"nested": []
},
{
"entity": "gift",
"data": {
"name": "Surprise"
},
"context": {
"shopping": [
"complete",
0
]
},
"nested": []
}
],
"consent": {
"functional": true
},
"id": "235d0d7bd7a213f2",
"trigger": "load",
"entity": "order",
"action": "complete",
"timestamp": 1700000200000,
"timing": 3.14,
"source": {
"count": 1,
"trace": "0a1b2c3d4e5f60718293a4b5c6d7e8f9",
"type": "collector",
"schema": "4"
}
}{
"name": "purchase",
"data": {
"map": {
"revenue": {
"map": {
"currency": {
"value": "EUR"
},
"amount": "data.value"
}
}
}
}
}window.plausible("purchase", {
"revenue": {
"currency": "EUR",
"amount": 462
}
})Page views and custom events
Apart from the pageview rule above, every event is a custom event named after
the rule's name, or the walkerOS event name. Plausible accepts custom
properties with scalar values only (strings, numbers, booleans) under props,
and revenue as { currency, amount }, as the examples above show.
Without loadScript, the calls wait in the plausible queue until a Plausible
script on your page processes them.