DOM & Event Listeners
The DOM API of Kixell Tag lets you measure clicks and send events to Google Analytics 4 directly from your HTML, using simple data- attributes, without writing any JavaScript or configuring Google Tag Manager.
Click measurement
To detect clicks on a DOM element, such as a button, a link or any other element, you must add the following attributes:
data-kt-dcdata-kt-en="super_event"
These two attributes are enough to trigger the super_event event when the element is clicked. This event will be automatically sent to Google Analytics 4.
Example:
<a data-kt-dc data-kt-en="super_event" href="#">Link</a>
Event parameters
You can add up to 5 parameters to the triggered event. Each parameter must be defined by a name and a value:
data-kt-ep="name1"to specify the parameter name.data-kt-ev="value1"to define the corresponding value.
These attributes must be added to the DOM element that also contains data-kt-dc and data-kt-en.
Example:
<a data-kt-dc data-kt-en="super_event" data-kt-ep="name1" data-kt-ev="value1" href="#">Link</a>
In this example, when the element is clicked, the super_event event will be triggered with the name1 parameter containing the value value1.
Additional parameters
You can add up to 4 additional parameters to the event using the following pairs:
data-kt-ep2anddata-kt-ev2data-kt-ep3anddata-kt-ev3data-kt-ep4anddata-kt-ev4data-kt-ep5anddata-kt-ev5
Full example:
<a
data-kt-dc
data-kt-en="super_event"
data-kt-ep="name1" data-kt-ev="value1"
data-kt-ep2="name2" data-kt-ev2="value2"
data-kt-ep3="name3" data-kt-ev3="value3"
data-kt-ep4="name4" data-kt-ev4="value4"
data-kt-ep5="name5" data-kt-ev5="value5"
href="#">
Link
</a>
In this example, when the element is clicked, the super_event event will be triggered with the following parameters:
name1containingvalue1,name2containingvalue2,name3containingvalue3,name4containingvalue4,name5containingvalue5.