Send events

Sending events is useful for tracking unique interactions, such as clicks on buttons, as well as monitoring conversions and goals, like adding items to the cart or subscribing to a newsletter. Custom events also help with testing and optimization, such as in A/B tests to analyze the impact of different interface variations. This expands analytics, allowing for flexible data collection and in-depth analysis of user behavior.

There are two ways to send attributes. The simpler and more convenient method is to attach HTML attributes to the elements you want to track clicks on. When the element is clicked, the analytics script will send the event. Alternatively, you can use JavaScript, which is more flexible as it allows sending events not only on clicks.

HTML attributes:

HTML
JS
<button data-s:event="Button click">
  Click
</button>

Properties

Sending custom props with an event allows you to pass additional data for analyzing user behavior. This helps with:

The properties that will be sent with page views or events can be compared in the widgets.

Syntax & Rules

HTML
JS
<button
  data-s:event="Event"
  data-s:event-props="theme=dark;lang=en;logged_in=true"
>
  Click
</button>

Custom path

By default, the analytics script sends the current page URL, trimming query parameters and the trailing slash. For example, https://example.com/home/ and https://example.com/home?param=value will be sent as https://example.com/home.

It is possible to modify the path that the analytics script sends.

IMPORTANT

The custom path specified for the page will also be sent with the events.

If you need to merge routes, for example, send /dashboard/29ab9322-0ba1-449a-ab9f-539dc3a62683/setting as /dashboard/[userId]/settings, you can do it by overriding the path:

HTML
JS
<button 
  data-s:event="Event" 
  data-s:event-path="/dashboard/[userId]/settings"
>
  Button
</button>

The script will send https://example.com/dashboard/[userId]/settings