Skip to content

Commit 3d6a7d4

Browse files
committed
add card-link and banner-link class for tracking
1 parent e8bc7e8 commit 3d6a7d4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/js/70-docs-ndl.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ 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+
1015
// if a card is 'selectable' then make it a click target
1116
// by taking the link from the card and wrapping the whole card in an anchor tag with that link
1217
// if the card contains more than one link, the first link is used
@@ -17,14 +22,19 @@ document.addEventListener('DOMContentLoaded', function () {
1722
var target = link.querySelector('a').getAttribute('href')
1823
var card = link.parentElement
1924
card.classList.add('selectable')
20-
const cardLink = createElement('a', 'link')
25+
const cardLink = createElement('a', 'link card-link')
2126
cardLink.setAttribute('href', target)
2227
moveElements(card, cardLink)
2328
card.appendChild(cardLink)
2429
card.addEventListener('click', function (e) {
2530
e.preventDefault()
2631
window.location.href = target
2732
})
33+
34+
// add a class to the link itself for tracking
35+
link.querySelectorAll('a').forEach(function (a) {
36+
a.classList.add('card-link')
37+
})
2838
})
2939
}
3040

0 commit comments

Comments
 (0)