Skip to content

Commit 36fc93c

Browse files
FIT-1010: add JS to track enterprise CTA using GA4 (#195)
1 parent 3aaf657 commit 36fc93c

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

fern/docs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@ favicon: ./images/favicon.ico
7777
analytics:
7878
ga4:
7979
measurement-id: G-326708547
80+
81+
js:
82+
- path: ./js/analytics-enterprise-cta.js
83+
strategy: afterInteractive
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
document.addEventListener('DOMContentLoaded', function() {
2+
const links = document.querySelectorAll('a[href^="https://humansignal.com/goenterprise"]');
3+
if (links.length === 0) {
4+
return;
5+
}
6+
links.forEach((link, index) => {
7+
link.addEventListener('click', function() {
8+
if (typeof gtag === 'function') {
9+
gtag('event', 'enterprise_cta_click', {
10+
button_index: index,
11+
button_text: link.innerText || '',
12+
target_url: link.href,
13+
page_path: window.location.pathname
14+
});
15+
}
16+
});
17+
});
18+
});
19+

0 commit comments

Comments
 (0)