Click events
Automatic click events
You can turn on automatic click events by adding a value in the Glean.initialize
configuration object.
Glean.js will create a global click listener to catch all clicks for elements that include one of the following data attributes:
data-glean-id
data-glean-label
data-glean-type
An example HTML button that will fire a click event:
Click event API
Glean.js provides an API for manually collecting click events.
When to use the GleanMetrics.recordElementClick
API
- You want to trigger click events with dynamic custom data overrides.
- You have an existing handler used across multiple UI elements and you do not want to give every single element new HTML attributes.
Usage
Try it out
To see automatic click events in action, check out our interactive playground.