Skip to content

Commit cad7476

Browse files
committed
added citation button & vis footer tracking
1 parent 5e57182 commit cad7476

4 files changed

Lines changed: 63 additions & 2 deletions

File tree

examples/project_website/base.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,24 @@
9393
</script>
9494
</body>
9595

96+
<!-- Matomo -->
97+
<script>
98+
// set this to true to enable Matomo tracking
99+
var enable_tracking = false;
100+
if (enable_tracking) {
101+
var _paq = window._paq = window._paq || [];
102+
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
103+
_paq.push(['trackPageView']);
104+
_paq.push(['enableLinkTracking']);
105+
(function () {
106+
var u = "//dev.openknowledgemaps.org/piwik_stats/";
107+
_paq.push(['setTrackerUrl', u + 'matomo.php']);
108+
_paq.push(['setSiteId', '1']);
109+
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
110+
g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s);
111+
})();
112+
}
113+
</script>
114+
<!-- End Matomo Code -->
115+
96116
</html>

examples/project_website/pubmed.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,24 @@
115115
</script>
116116
</body>
117117

118+
<!-- Matomo -->
119+
<script>
120+
// set this to true to enable Matomo tracking
121+
var enable_tracking = false;
122+
if (enable_tracking) {
123+
var _paq = window._paq = window._paq || [];
124+
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
125+
_paq.push(['trackPageView']);
126+
_paq.push(['enableLinkTracking']);
127+
(function () {
128+
var u = "//dev.openknowledgemaps.org/piwik_stats/";
129+
_paq.push(['setTrackerUrl', u + 'matomo.php']);
130+
_paq.push(['setSiteId', '1']);
131+
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
132+
g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s);
133+
})();
134+
}
135+
</script>
136+
<!-- End Matomo Code -->
137+
118138
</html>

vis/js/templates/buttons/CitationButton.jsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ import { connect } from "react-redux";
44
import { openCitationModal } from "../../actions";
55
import { useLocalizationContext } from "../../components/LocalizationProvider";
66
import { STREAMGRAPH_MODE } from "../../reducers/chartType";
7+
import useMatomo from "../../utils/useMatomo";
78

89
const CitationButton = ({ isStreamgraph, onClick }) => {
910
const localization = useLocalizationContext();
11+
const { trackEvent } = useMatomo();
12+
13+
const handleClick = () => {
14+
onClick();
15+
trackEvent("Added components", "Open cite modal", "Cite button");
16+
};
1017

1118
return (
1219
// html template starts here
@@ -18,7 +25,7 @@ const CitationButton = ({ isStreamgraph, onClick }) => {
1825
? localization.cite_title_sg
1926
: localization.cite_title_km
2027
}
21-
onClick={onClick}
28+
onClick={handleClick}
2229
>
2330
<span id="citationlink">
2431
<i className="fa fa-quote-right fa-fw" aria-hidden="true"></i>{" "}

vis/js/templates/footers/CreatedBy.jsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,28 @@ import React from "react";
33
import okmapsRoundLogo from "../../../images/okmaps-logo-round.svg";
44

55
import { getDateTimeFromTimestamp } from "../../utils/dates";
6+
import useMatomo from "../../utils/useMatomo";
67

78
const CreatedBy = ({ timestamp, faqsUrl }) => {
89
const dateTime = getDateTimeFromTimestamp(timestamp);
10+
const { trackEvent } = useMatomo();
11+
12+
const trackVisLink = () =>
13+
trackEvent(
14+
"Added components",
15+
"Open this visualization",
16+
"Visualization link in footer"
17+
);
918

1019
return (
1120
<div className="builtwith" id="builtwith">
1221
<img src={okmapsRoundLogo} alt="OKMaps round logo" />{" "}
13-
<a href={window.location.href} target="_blank" rel="noreferrer">
22+
<a
23+
href={window.location.href}
24+
target="_blank"
25+
rel="noreferrer"
26+
onClick={trackVisLink}
27+
>
1428
This visualization
1529
</a>{" "}
1630
was created by{" "}

0 commit comments

Comments
 (0)