Named clicks
Give an element a data-trail name and every click on it, or on anything inside it, becomes an event with that name:
html
<button data-trail="Signup">Create account</button>
<a href="/pricing" data-trail="Pricing from hero">
<span>See pricing</span>
</a>- The closest element with
data-trailwins, so a click on the<span>above recordsPricing from hero. - The event looks the same as
trail.track('Signup'), so it shows in the Events panel and can be a goal. - Named clicks are sent in full mode, which includes the default mode after
consent(true)oridentify(). Private visitors do not send them, andt.p.jsdoes not include them.
Trail does not record every click on the page. Only the elements you name are tracked, plus links to other sites (outbound clicks), which are recorded in every mode.
Next
- Count a named click as a goal.
- Send richer events with custom events.