Skip to content

Commit 38311b3

Browse files
committed
[feature] Track clicks on features and faqs
1 parent b4e2ced commit 38311b3

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

js/faq.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,15 @@ document.addEventListener("DOMContentLoaded", function () {
5353
openFragment(event.target.location.hash);
5454
});
5555
});
56+
57+
document.addEventListener("DOMContentLoaded", function () {
58+
if (typeof _paq === "undefined") {
59+
return;
60+
}
61+
document.querySelectorAll("aside.faq .menu-list > li > a").forEach(function (link) {
62+
link.addEventListener("click", function () {
63+
var linkText = link.textContent.trim();
64+
_paq.push(["trackEvent", "FAQ", "Open", linkText]);
65+
});
66+
});
67+
});

js/modal.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,15 @@ document.addEventListener("DOMContentLoaded", () => {
8181
}
8282
}
8383
});
84+
85+
document.addEventListener("DOMContentLoaded", function () {
86+
if (typeof _paq === "undefined") {
87+
return;
88+
}
89+
document.querySelectorAll("a.open-modal").forEach(function (link) {
90+
link.addEventListener("click", function () {
91+
var linkText = link.textContent.trim();
92+
_paq.push(["trackEvent", "Feature", "Modal", linkText]);
93+
});
94+
});
95+
});

theme/templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@
228228
</div>
229229
</footer>
230230
<script src="{{ SITEURL }}/theme/js/theme.min.js?v=2" defer></script>
231-
{% block scripts %}{% endblock %}
232231
{% if MATOMO_SITE_ID %}
233232
<!-- Matomo -->
234233
<script>
@@ -259,5 +258,6 @@
259258
></noscript>
260259
<!-- End Matomo Code -->
261260
{% endif %}
261+
{% block scripts %}{% endblock %}
262262
</body>
263263
</html>

theme/templates/page-faq.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{% extends "page.html" %}
22
{% block scripts %}
3-
<script src="{{ SITEURL }}/theme/js/faq.min.js" defer></script>
3+
<script src="{{ SITEURL }}/theme/js/faq.min.js?v=2" defer></script>
44
{% endblock %}

theme/templates/page-modal.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% extends "page.html" %}
22
{% block scripts %}
33
<div id="modal-container"></div>
4-
<script src="{{ SITEURL }}/theme/js/modal.min.js" defer></script>
4+
<script src="{{ SITEURL }}/theme/js/modal.min.js?v=2" defer></script>
55
{% endblock %}

0 commit comments

Comments
 (0)