Type-safe, discoverable parameters live under RoundlyConsulting\Plausible\Enums. Anywhere an enum is accepted, the equivalent string still works:
| Enum | Used by | Values |
|---|---|---|
Metric | metrics() on every terminal | visitors, visits, pageviews, views_per_visit, bounce_rate, visit_duration, events, scroll_depth, conversion_rate, group_conversion_rate, total_revenue, average_revenue, time_on_page, exit_rate, percentage |
Period | period() and the v2 date range | day, 7d, 30d, month, 6mo, 12mo, year, all, custom |
Interval | interval() for timeseries and breakdowns | minute, hour, date, week, month |
Property | v1 breakdown(), property(), cursor() | event:name, event:page, event:hostname, event:goal, visit:source, visit:referrer, visit:utm_medium, visit:utm_source, visit:utm_campaign, visit:utm_content, visit:utm_term, visit:device, visit:browser, visit:browser_version, visit:os, visit:os_version, visit:country, visit:region, visit:city, visit:entry_page, visit:exit_page |
Dimension | v2 dimensions() and where() | every Property value, plus visit:channel and the time:hour, time:day, time:week, time:month buckets |
FilterOperator | where() / orWhere() | is, is_not, contains, contains_not, matches, matches_not, and, or, not, has_done, has_not_done |
GoalType | CreateGoalRequest | event, page |
For a custom event property use Property::custom('plan') or Dimension::custom('plan'), which return the event:props:plan string.
Helpers
Via enums-for-laravel every enum carries the Helpers surface — values(), labels(), options(), toOptions(), validationRule(), name and label lookups, and the is()/when* helpers. Handy for dashboards, pickers and validating a chosen parameter:
use RoundlyConsulting\Plausible\Enums\Dimension;
use RoundlyConsulting\Plausible\Enums\Metric;
use RoundlyConsulting\Plausible\Enums\Period;
use RoundlyConsulting\Plausible\Enums\Property;
Metric::values(); // 'visitors', 'visits', 'pageviews', … — the raw wire keys
Metric::validationRule(); // 'in:visitors,visits,pageviews,…' for request validation
Period::toOptions(); // ['day' => 'Day', '7d' => 'Seven Days', …] for a <select>
Period::options(); // list of {value, label, name} DTOs for JS/Inertia
Period::fromName('SixMonths'); // Period::SixMonths
Period::SevenDays->readable(); // 'Seven Days'
Dimension::EventName->readable(); // 'Event Name'
Metric::ViewsPerVisit->readable(); // 'Views Per Visit'
Property::custom('plan'); // 'event:props:plan'
Dimension::custom('plan'); // 'event:props:plan'Validating user input
use RoundlyConsulting\Plausible\Enums\Metric;
use RoundlyConsulting\Plausible\Enums\Period;
$validated = $request->validate([
'metric' => ['required', Metric::validationRule()],
'period' => ['required', Period::validationRule()],
]);
$result = Plausible::stats()
->query()
->metrics(Metric::from($validated['metric']))
->period(Period::from($validated['period']))
->aggregate();Labels vs wire values
value, values(), validationRule() and custom() always emit the raw API strings. Only the display label differs: Metric, Interval, GoalType and FilterOperator derive clean labels from the value (views_per_visit → Views Per Visit), while Period, Dimension and Property — whose values are abbreviations like 7d or ns:field tokens like event:name — derive them from the case name (SevenDays → Seven Days).
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.