Visualize your shop's average order value, orders per month and more customizable graphs
npm install @pinelab/vendure-plugin-metrics
A plugin to visualize your shops most important metrics. Includes server side visitor tracking to calculate conversion rate.
vendure-config.ts
:Advanced Metrics
to your dashboard.Metric results are cached in memory to prevent heavy database queries every time a user opens its dashboard.
To enable visitor tracking, you need to call the mutation pageVisit
on the client to log a visit. Without this mutation, no visitors are tracked at all.
You can optionally pass inputs to the pageVisit, which will be persisted on each request.
These inputs currently aren't used, but you can write a custom metric to get, for example the top visited products, or pages.
:warning: Not legal advice.
Ip addresses and user agents are anonymized, and can not be reversed after 24 hours. This also means the same visitor will be seen as a new visitor after 24 hours.
This should make this plugin compliant with GDPR, and allow you to track visits without cookie consent.
The default session length is 30 minutes. This can be overridden via sessionLengthInMinutes
option. This means that new request from the same visitor after 30 minutes will be seen as a new visitor. Anything requests within the 30 minutes of the previous request will be counted as the same visitor.
order.totalWithTax
of the orders per monthYou can implement the MetricStrategy
interface and pass it to the MetricsPlugin.init()
function to have your custom metric visible in the Widget.
Below is the implementation of the conversion metric, already included in the plugin, but it serves as an example of how to implement a custom metric.
Special thanks to@dalyathan for his contributions on this plugin.