Events
Tracking events
If you want an agent that is fully integrated with your site, tell us about the events your users perform. This gives Mezura the signals it needs to measure conversions and run better experiments.
Sending an event
It’s very simple. Once the tracker has loaded, it adds a send_event method to the same $mezura object you configured during installation. (Your configuration lives under $mezura.data; methods like this one live directly on $mezura.) Call it with the event name whenever something happens on your site — you can optionally pass a second argument with any details you want to attach:
// Just the event name:
$mezura.send_event("purchase");
// Or with extra details:
$mezura.send_event("purchase", { value: 99, currency: "USD" });
Call it right when the event occurs — for example after a successful checkout, when a form is submitted, or when a video is played. Use a short, consistent name for each kind of event.
Parameters
| Argument | Type | Required | Description |
|---|---|---|---|
| event_name | string | Required | A short name identifying the event, e.g. purchase, signup, add_to_cart. Use the same name for the same action. |
| payload | object | Optional | Any extra details about the event, as a plain object — for example an order value, a plan name, or a product id. We store it alongside the event so you can use it later; the exact shape is entirely up to you. |
Where your events show up
Once you start sending events, they appear in your Mezura panel. The first time a given event fires, we add it to your list — over time you’ll see all of your site’s events collected in one place, ready to be used as conversion goals for experiments.
$mezura object is available once the tracker script has loaded.