Track Events in Prodio
Besides pageviews, Prodio also allows you to track custom events that occur on your website. There are two ways to record events in Prodio: using the data attributes property or JavaScript.
Using Data Attributes
To enable events, simply add a special data property to the element you want to track.
For example, you might have a button with the following code:
<button id="signup-button">Sign up</button>
Add a data property with the following format:
data-Prodio-event="{event-name}"
Your button element would now look like this:
<button id="signup-button" data-Prodio-event="Signup button">Sign up</button>
When the user clicks on this button, Prodio will record an event named Signup button.
You can optionally pass along event_data
with the data-Prodio-event-*
annotation:
<button
id="signup-button"
data-Prodio-event="Signup button"
data-Prodio-event-email="bob@aol.com"
data-Prodio-event-id="123">
Sign up
</button>
The additional properties will result in:
{ email: "bob@aol.com", id: "123" }
being recorded with the Signup button event name.
Note:
- Event data cannot be sent without an event name.
- All event data will be saved as strings using this method. If you want to save event data as numeric, dates, booleans, etc., use the JavaScript method below.
- Other event listeners inside the element will not be triggered.
Using JavaScript
You can also record events manually using the window.Prodio
object. To accomplish the same thing as the above data-* method, you can do:
const button = document.getElementById('signup-button');
button.onclick = () => Prodio.track('Signup button');
In this case, Prodio will record an event named Signup button.
If you want to record dynamic data, refer to the Tracker functions in the Prodio documentation.
View Events
Once your events are recorded, they will be available on your website’s Events page.
View Event Properties
Your custom data can be accessed under the Properties tab on the Events page. This section will show you all the custom data properties you saved, as well as a breakdown of all the values.
For further assistance, visit our Help Center or contact the support team.