-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy patheventhandler.js
32 lines (28 loc) · 998 Bytes
/
eventhandler.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import d3 from "d3";
/**
* Add event listeners to links and buttons to send Google Analytics events
*/
export default function () {
document.addEventListener("DOMContentLoaded", () => {
d3.selectAll(".download-data").on("click", function () {
const link = this.href;
const eventText = this.text;
ga("send", "event", "Download Data", link, eventText);
});
d3.selectAll(".external-link").on("click", function () {
const link = this.href;
const eventText = this.text;
ga("send", "event", "External Link", link, eventText);
});
d3.selectAll(".top-download-page").on("click", function () {
const link = this.href;
const eventText = this.text;
ga("send", "event", "Top-Download Page", link, eventText);
});
d3.selectAll(".top-download-file").on("click", function () {
const link = this.href;
const eventText = this.text;
ga("send", "event", "Top-Download File", link, eventText);
});
});
}