Skip to content

Commit 97fb050

Browse files
authored
add card-link and banner-link class for tracking (#302)
Add classes to links in cards and the banner on neo4j.com/docs so that we can track clicks on those links accurately as linkClicks in GTM. - Adds `banner-link` class to `<a>` tags inside a div with class `banner`. - Adds `card-link` class to `<a>` tags inside a `.link` div in a `.cards` div beneath the banner
1 parent e8bc7e8 commit 97fb050

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/css/themes.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ body.docs .navbar .navbar-item.getting-started-cta .navbar-link:active {
131131

132132
body.docs .banner .button .banner-link {
133133
background: var(--banner-background-color);
134-
color: var(--banner-text-color);
134+
/* color: var(--banner-text-color); */
135135
}
136136

137-
body.docs .banner .button .banner-link:hover {
137+
/* body.docs .banner .button .banner-link:hover {
138138
background: rgba(var(--banner-hover-color));
139-
}
139+
} */
140140

141141
body.docs .banner .button .banner-link:active {
142142
background: rgba(var(--banner-background-color));

src/js/70-docs-ndl.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ document.addEventListener('DOMContentLoaded', function () {
77
}
88
}
99

10+
// add a class to the banner link for tracking
11+
document.querySelectorAll('.banner a').forEach(function (a) {
12+
a.classList.add('banner-link')
13+
})
14+
15+
// add a class to the link itself for tracking
16+
document.querySelectorAll('.cards:not(.bottom-cards) .link a').forEach(function (a) {
17+
a.classList.add('card-link')
18+
})
19+
1020
// if a card is 'selectable' then make it a click target
1121
// by taking the link from the card and wrapping the whole card in an anchor tag with that link
1222
// if the card contains more than one link, the first link is used
@@ -17,7 +27,7 @@ document.addEventListener('DOMContentLoaded', function () {
1727
var target = link.querySelector('a').getAttribute('href')
1828
var card = link.parentElement
1929
card.classList.add('selectable')
20-
const cardLink = createElement('a', 'link')
30+
const cardLink = createElement('a', 'link card-link')
2131
cardLink.setAttribute('href', target)
2232
moveElements(card, cardLink)
2333
card.appendChild(cardLink)

0 commit comments

Comments
 (0)