Skip to content

Track clicks without code

Track clicks on buttons and links by adding an HTML attribute.

Mark any element with data-loomduct-event, and Loomduct sends an event when someone clicks it. No JavaScript needed.

Before you start

  • Loomduct installed on your site. See the Quick start.

Steps

Turn on click events

Click events are off by default.

Pass dataAttributes: true to webAnalytics(), or add data-click-events to the script tag.

src/loomduct.ts
import { Loomduct } from '@loomduct/js'
import { webAnalytics } from '@loomduct/js/web-analytics'

export const loomduct = new Loomduct({
  token: 'lmt_your_project_token',
  plugins: [webAnalytics({ dataAttributes: true })],
})

Mark the element

Add data-loomduct-event with the event name. Every other data-loomduct-* attribute becomes a property:

pricing.html
<button data-loomduct-event="signup_clicked" data-loomduct-plan="pro">
  Start free trial
</button>

A click sends signup_clicked with { plan: 'pro' }. A click on anything inside the element counts too.

Good to know:

  • The property name is the rest of the attribute name: data-loomduct-plan-type becomes plan-type.
  • Property values are always text, cut to 2,000 characters.
  • The event name follows the same rules as custom events: not empty, and it cannot start with $.

Check that it worked

Click the element on your site. In the dashboard, open Events. The event shows up with its properties.