Track actions with HTML attributes
Add data-cjm-* attributes without a separate selector rule.
If you can edit website HTML, add attributes directly to buttons and forms. The tracker runs once the Pixel initializes; you do not also need the same event under Events → Configured events.
Configure a button
- Install the Pixel and connect the banner.
- Add these attributes to your actual website button.
- Publish, reload, and click the nested text too.
- Look for
demo_clickin Installation & test → Live verification.
<button id="richiedi-demo"
data-cjm-event="demo_click"
data-cjm-trigger="click"
data-cjm-data-plan="pro"
data-cjm-data-team-size="12"
data-cjm-data-trial="true">
<span>Richiedi demo</span>
</button>Supported attributes
| Attribute | Required | Value and result |
|---|---|---|
data-cjm-event | Yes | Nonempty event name. |
data-cjm-trigger | No | Trigger, defaults to click. One trigger per element. |
data-cjm-data-<key> | No | Extra field. Parsed as JSON when valid, otherwise kept as text. |
data-cjm-prevent-default | No | Its presence prevents the default action only for submit, even if its written value is false. |
The example sends plan: 'pro', 'team-size': 12, and trial: true. Hyphens in keys are preserved. For complex JSON use suitable HTML quotes, for example data-cjm-data-details='{"section":"pricing"}'.
Registered triggers are click, submit, focus, blur, change, input, touchstart, touchend, mouseenter, mouseleave, contextmenu, keydown, and keyup. Current limitation: mouseenter and mouseleave do not normally bubble to the document listener; configure these through dashboard DOM events. Focus and Blur are listened to in capture mode.
The nearest ancestor carrying data-cjm-event is selected, including clicks on children and dynamically added elements. Nested tracked elements use the nearest one. The tracker adds tag, id, optional href, and up to 100 characters of text. Avoid custom keys with those names unless you intend to override them.
Forms and limitations
A <form> can use data-cjm-trigger="submit", but this records an interaction, not contact details or server confirmation. Do not add data-cjm-prevent-default to a normal form: it would stop submission unless your website explicitly handles the request.
Attributes have no dedicated options for tags, Meta/GTM, or ecommerce. Naming an event purchase does not make it a structured purchase: use trackEcommerce. For contacts use trackLead.
For duplicate events, check overlapping DOM rules or manual calls. For missing events check attributes, trigger, and consent.