Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the customization of the name of DOM elements when clicked #501

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jonathanghm
Copy link

Objective
Enable the customization of the name of DOM elements when clicked.

Motivation
1. Independence from the content of the DOM element:
By using a custom attribute, the logic for event tracking is separated from the content of the element. This provides flexibility to change the content without affecting the tracking logic.

2. Avoids internationalization issues:
In multilingual applications, the text of the element may change depending on the language, which could complicate tracking. A custom attribute can provide a more stable identifier.

2. Privacy enhancement:
There may be scenarios where an element contains sensitive information, like email, name or passwords. This enhances the masking option already provided by clarity and additionally gives the analytics more context about the action.

How does it work?
By using the custom attribute "data-clarity-event" on the clickable DOM element, this will be considered as the default event name.
If the custom attribute "data-clarity-event" does not exist on the element, the current logic will be followed to obtain the name (textContent, value, or alt).

@jonathanghm
Copy link
Author

@microsoft-github-policy-service agree

@legz
Copy link

legz commented Oct 8, 2024

This evolution would be very useful in our context (we have buttons without text labels that Clarity can understand).
Would it be possible to review this PR please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants