Skip to content

Commit 3ab1ce8

Browse files
authored
fix: add events in each card for tracking click (#158)
* fix: add events in each card for tracking click * fix: add tracking js file for individual card tracking
1 parent 1e32454 commit 3ab1ce8

File tree

3 files changed

+193
-23
lines changed

3 files changed

+193
-23
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
document.addEventListener("DOMContentLoaded", function () {
2+
const cards = document.querySelectorAll(
3+
".landing-tutorial-card, .landing-integration-item, .landing-community-support-item, .landing-feature-item"
4+
);
5+
cards.forEach((card) => {
6+
card.addEventListener("click", () => {
7+
const eventName = card.getAttribute("data-clarity-event") || "card_click";
8+
const title = card.getAttribute("data-clarity-title") || "unknown";
9+
const url = card.getAttribute("data-clarity-url") || "unknown";
10+
11+
if (window.clarity && typeof window.clarity === "function") {
12+
// Fire a named event
13+
window.clarity("event", eventName);
14+
15+
// Attach extra metadata
16+
window.clarity("set", "cardTitle", title);
17+
window.clarity("set", "cardUrl", url);
18+
}
19+
});
20+
});
21+
});

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ extra_javascript:
2525
- js/search-tracking.js
2626
- https://buttons.github.io/buttons.js
2727
- js/reo.js
28+
- js/landing-individual-card-ms-tracking.js
2829
extra:
2930
# social:
3031
# - icon: fontawesome/brands/linkedin

0 commit comments

Comments
 (0)