Download the PHP package setono/sylius-plausible-plugin without Composer
On this page you can find all versions of the php package setono/sylius-plausible-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download setono/sylius-plausible-plugin
More information about setono/sylius-plausible-plugin
Files in setono/sylius-plausible-plugin
Package sylius-plausible-plugin
Short Description Start tracking your visitors with Plausible.io
License MIT
Informations about the package sylius-plausible-plugin
Sylius plugin integrating Plausible Analytics
Use Plausible Analytics to track visitors and events in your Sylius store.
This plugin supports Sylius 1.x.
Installation
Step 1: Install and enable the plugin
Step 2: Register the tag bag bundle
The plugin outputs its JavaScript through setono/tag-bag-bundle.
If the bundle isn't registered already (Symfony Flex does this for you), add it to config/bundles.php:
Step 3: Render the tag bag in your shop layout
Nothing is rendered until you call the tag bag's Twig functions. Add them to your shop layout:
[!IMPORTANT] If you skip this step the plugin will appear to work, but no tracking code is ever written to the page.
Step 4: Add the Plausible script identifier trait to your Channel entity
Make sure the channel resource points at your own class:
Step 5: Import routes
Step 6: Update your database schema
Usage
Configure Plausible per channel
Navigate to Marketing > Plausible in the admin panel to configure the Plausible script for each channel.
You can enter the Plausible script in any of the following formats:
- Identifier only:
pa-hb0WlWkUb5U3qhSS-vd-a - Full URL:
https://plausible.io/js/pa-hb0WlWkUb5U3qhSS-vd-a.js - HTML snippet:
<script async src="https://plausible.io/js/pa-hb0WlWkUb5U3qhSS-vd-a.js"></script>
The plugin will normalize any of these formats and output the correct script tag on your storefront.
Disabling tracking
Tracking is enabled by default. Turn it off in environments that shouldn't report to Plausible, for instance staging:
While disabled, none of the tracking services are registered at all, so no listener runs and no work is done. The admin UI stays available, so you can still configure your channels.
Self-hosted Plausible
If you run Plausible Community Edition, point the plugin at your own host:
The script is then loaded from https://analytics.example.com/js/<identifier>.js. Defaults to https://plausible.io.
What gets tracked
The plugin sends five custom events. Each one is written to the page as a plausible(...) call by
setono/tag-bag, so an event triggered by a form submission fires
on the next page the visitor sees.
| Event name | Fires when |
|---|---|
Begin Checkout |
The visitor lands on the checkout start route |
Address |
The addressing step is completed |
Select Shipping Method |
The shipping step is completed |
Select Payment Method |
The payment step is completed |
Purchase |
The visitor reaches the thank you page |
Properties
Every event carries the properties of the order it relates to. For the four checkout events that is the
current cart; for Purchase it is the completed order.
| Property | Type | Notes |
|---|---|---|
order_id |
int | |
order_number |
string | |
order_total |
float | Major units, i.e. 100.0, not 10000 |
tax_total |
float | |
shipping_total |
float | |
order_promotion_total |
float | Negative |
payment_method |
string | Payment method code |
shipping_method |
string | Shipping method code |
coupon_code |
string |
Properties that are null or an empty string are left out, so an order without a coupon has no
coupon_code property rather than an empty one. No customer data is sent.
The Purchase event additionally carries revenue:
[!NOTE] Custom properties and revenue have to be enabled in your Plausible dashboard before they show up. See custom properties and revenue tracking.
Tracking your own events
Dispatch the plugin's event and it is turned into a plausible(...) call for you:
To add properties to the events the plugin already sends, listen to the same event class. The subscriber
that renders the tag runs at priority -100, so a listener at the default priority still gets a say:
[!WARNING] Property values end up inside an inline
<script>tag. The plugin escapes them, but keep customer supplied data out of your properties unless you have a good reason to send it — Plausible is not the place for personal data.
All versions of sylius-plausible-plugin with dependencies
doctrine/dbal Version ^3.2
doctrine/orm Version ^2.0
doctrine/persistence Version ^2.0 || ^3.0
psr/event-dispatcher Version ^1.0
psr/log Version ^1.1 || ^2.0 || ^3.0
setono/doctrine-orm-trait Version ^1.2
setono/tag-bag Version ^2.4
setono/tag-bag-bundle Version ^3.0
sylius/admin-bundle Version ^1.0
sylius/channel Version ^1.0
sylius/core Version ^1.0
sylius/core-bundle Version ^1.0
sylius/order Version ^1.0
sylius/resource-bundle Version ^1.6
sylius/ui-bundle Version ^1.0
symfony/config Version ^6.4
symfony/dependency-injection Version ^6.4
symfony/event-dispatcher Version ^6.4
symfony/form Version ^6.4
symfony/http-foundation Version ^6.4
symfony/http-kernel Version ^6.4
symfony/options-resolver Version ^6.4
symfony/security-bundle Version ^6.4
symfony/security-csrf Version ^6.4
symfony/serializer Version ^6.4.30
twig/twig Version ^2.15 || ^3.22
webmozart/assert Version ^1.12