Custom events
Besides pageviews, Lienks counts your own events, such as button clicks or form submissions. One call is all it takes.
Track an event
Call window.lienks.event('signup_clicked') wherever something should be counted. This works once the Lienks snippet is on your page (see Quick start). The script provides window.lienks.
For example on a button:
<button onclick="window.lienks?.event('signup_clicked')">Sign up</button> Or in JavaScript with an event listener:
document.querySelector('#signup').addEventListener('click', () => {
window.lienks?.event('signup_clicked');
}); The ?. means nothing happens if the script isn’t loaded, for example because of an ad blocker, instead of an error on your page.
Event names
An event name starts with a lowercase letter, followed by lowercase letters, digits and underscores, up to 100 characters long:
^[a-z][a-z0-9_]{0,99}$ - Valid:
signup_clicked,download_pdf,newsletter_form_sent - Not valid:
Signup Clicked(capital letters and a space),signup-clicked(a hyphen),1st_click(starts with a digit)
pageview is reserved and can’t be used as an event name.
Invalid names are discarded: nothing is sent to Lienks and there is no error message. If an event doesn’t show up in the dashboard, check its name first.
Tip: pick short, consistent names, for example object_action, so they’re easy to read in the dashboard.
Use it with frameworks
In React, Vue, Svelte, Next.js and similar, you use the same call in your click handler, with window.lienks?.event(...).
In TypeScript projects, declare window.lienks so the type checker knows it:
declare global {
interface Window {
lienks?: { event: (eventName: string) => void };
}
}
export {}; See your events
In your site’s dashboard, the Custom Events card shows which events were triggered. The Latest Events view lists the last 50 events with time, name, page, referrer, browser, operating system, device, country and bot status.
More on this in Metrics and filters and Events.
Good to know
- An event has only a name. You can’t send additional data such as properties or values.
- Each event records the page path and the referrer.
- Custom events count towards your plan’s event allowance, like pageviews (Billing and plans). Known bots are not counted.
- Whether and how visitors are recognised, and whether cookies are set, depends on the tracking mode, not on the event (Tracking modes).
- The call runs in the background and never disturbs your page. It returns nothing and has no callback.