First, make sure your tracking setup includes the second line as shown below
This snippet creates a global function called
plausible which can be used to trigger custom events from anywhere in your code.
Here’s what triggering a custom event looks like
The event name can be anything. As a second parameter, you can also send an object with options. The only supported option at the moment is
callback – a function that is called once the event is logged successfully.
This is the whole extent of the API. If you want to trigger form submissions, button clicks etc. you need to implement the code for that yourself. This is an example of code we use to track custom events (trial signups) on our own website:
And here's an example of the code you need to insert if you're using the Contact Form 7 plugin on WordPress and want to see the number of visitors who use the contact form. In this example, there are two contact forms on two different pages and this is the code you should insert in the
Create a custom event goal in your Plausible Analytics account
When you start sending custom events to Plausible Analytics, they won’t show up automatically. You’ll have to configure the goal for the conversion numbers to show up.
To configure a goal, go to your website’s settings in your Plausible Analytics account and scroll down to the "Goals" section. You should see an empty list with a prompt to add a goal.
Click on the "+ Add goal" button to go to the goal creation form.
Custom event as the goal trigger and enter the name of the custom event you are triggering. The names must be an exact match to the one on your site for the conversions to show up in your analytics dashboard.
Next, click on the "Add goal" button and you’ll be taken back to the Goals page. When you navigate back to your Plausible Analytics dashboard, you should see the number of visitors who triggered the custom event. Goal conversions are listed at the very bottom of the dashboard.