summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarel Ben-Attia <harelba@gmail.com>2021-11-27 10:49:37 +0200
committerHarel Ben-Attia <harelba@gmail.com>2021-11-27 10:49:37 +0200
commite1f2a15bd2b6f5c6b54f061d3895f988bf14c28d (patch)
tree03e30dc1e6865ec32f2ef97e56799c35b8204f3e
parent978209d4578f26d26018e26d671912e514e80b53 (diff)
fix GA site logic to match new download structure
-rw-r--r--mkdocs/docs/js/google-analytics.js15
1 files changed, 6 insertions, 9 deletions
diff --git a/mkdocs/docs/js/google-analytics.js b/mkdocs/docs/js/google-analytics.js
index 4c0829d..186332e 100644
--- a/mkdocs/docs/js/google-analytics.js
+++ b/mkdocs/docs/js/google-analytics.js
@@ -1,6 +1,7 @@
// Monitor all download links in GA
var dlCnt = 0;
+var tocCnt = 0;
function GAizeDownloadLink(a) {
var url = a.href;
@@ -8,15 +9,10 @@ function GAizeDownloadLink(a) {
if (x != -1) {
url = url.substr(0, x);
}
- var url_test = url.match(/^https?:\/\/.+(\/rpms\/.*\.rpm|\/deb\/.*\.deb|\/single-binary\/Darwin\/.*\/q|\/archive\/.*\.tar\.gz|\/archive\/.*\.zip|\/windows\/.*\.exe)$/i);
+ var url_test = url.match(/^http.*(archive\/|releases\/)(?<path>.*)/);
if (url_test) {
- console.log("Converting download link to be GA aware: " + url);
- if (url_test.length > 1) {
- var event_action = url_test[1];
- } else {
- var event_action = 'unknown_action';
- }
- a.event_action = event_action;
+ a.event_action = url_test.groups.path;
+ console.log("Converting download link to be GA aware: " + url + " . download path is " + a.event_action);
dlCnt = dlCnt + 1;
a.onclick = function() {
console.log("Sending GA event for link" + url);
@@ -31,6 +27,7 @@ function GAizeDownloadLink(a) {
}
function GAizeTOCLink(l) {
+ tocCnt = tocCnt + 1;
l.onclick = function() {
url_test = l.href.match(/^https?:\/\/.+(#.*)$/i);
toc_name = url_test[1];
@@ -55,5 +52,5 @@ window.onload = function() {
for (i = 0; i < toc_links.length; i++) {
GAizeTOCLink(toc_links[i]);
}
- console.log("Converted " + dlCnt + " links to be GA aware");
+ console.log("Converted " + dlCnt + " download links and " + tocCnt + " TOC links to be GA aware");
}