Data Action Listeners
Data Action Listeners is a feature of SlideRule Analytics' GA4 integration that allows Shopify dvelopers and designers to easily track user interactions with HTML elements directly from code using data attributes.
- Track click events on elements with data-action="click".
- Track view events when elements with data-action="view" enter the user's browser window.
- Collect any attributes you want to send to GA4.
- Click Tracking:
- action = "click"
- object = "call to action"
- index_number = "12314"
- location = "hero"
- text = "Shop"
- class = "class1 class3"
- View Tracking:
- action = "view"
- object = "introduction section"
- text = "Welcome to the Introduction Section"
The following attributes are tracked by default for both click and view events:
- class
- id as element_id
- src
- role
- href as url
- innerText as text
- target
and all aria elements
Any data-attribute will also be tracked. For instance
data-my-label="my button"
will be tracked as
my_label = "my button"
You can customize the event name in two ways:
- add a data-object attribute. For instance, data-object="style" would result in an event name of style_click.
- Add an data-event-name attribute. For instance, data-event-name="style selection" would result in an event name of style_selection.
Note in both cases you still need the data-action="click" attribute.
Per Google Analytics 4 naming conventions all property names are snake cased.
All property values values are lower cased to avoid unintentionally duplicated values.
Make sure you observe GA4 collection limits.
In particular:
- Length of event-parameter name: 40 characters
- Length of event name: 40 characters. If an event exceeds 40 characters, the event will not be reported as a conversion (if you mark the event as a conversion) because the appended "_c" will be missing.
- Event parameters per event: 25 event parameters
Make sure you do not send personally identifiable information to GA4.
