Skip to content

Commit

Permalink
added more stuff from the original site, include GA link conversion, but
Browse files Browse the repository at this point in the history
not sure it's working yet
  • Loading branch information
harelba committed Feb 8, 2020
1 parent 8cbe4cc commit 6d08df4
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
Empty file added mkdocs/docs/fsg9b9b1.txt
Empty file.
1 change: 1 addition & 0 deletions mkdocs/docs/google0efeb4ff0a886e81.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
google-site-verification: google0efeb4ff0a886e81.html
Binary file added mkdocs/docs/img/torii-favicon.ico
Binary file not shown.
50 changes: 50 additions & 0 deletions mkdocs/docs/js/google-analytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

ga('create', 'UA-48316355-1', 'auto');
ga('require', 'displayfeatures');
//ga('require', 'linkid', 'linkid.js');
ga('send', 'pageview');

// Monitor all download links in GA
window.onload = function() {
var a = document.getElementsByTagName('a');
var cnt = 0;
for (i = 0; i < a.length; i++) {
var url = a[i].href;
var x = url.indexOf("?");
if (x != -1) {
url = url.substr(0, x);
}
var url_test = url.match(/^https?:\/\/.+(\.rpm|\.deb|\/q|\.tar\.gz|\.zip|\.bat|\.exe)$/i);
if (url_test) {
console.log("Converting url to be GA aware: " + url);
if (url_test.length > 1) {
var event_action = url_test[1];
} else {
var event_action = 'unknown_action';
}
a[i].event_action = event_action;
cnt = cnt + 1;
a[i].onclick = function() {
console.log("Sending GA event for link" + url);
var that = this;
ga('send', 'event', 'Downloads', 'Click on ' + this.event_action, this.getAttribute('href'));
setTimeout(function() {
location.href = that.href;
}, 500);
return false;
};
}
}
console.log("Converted " + cnt + " links to be GA aware");
}
2 changes: 2 additions & 0 deletions mkdocs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ extra:
link: 'https://www.linkedin.com/in/harelba'
extra_css:
- 'stylesheets/extra.css'
extra_javascript:
- 'js/google-analytics.js'
markdown_extensions:
- meta
- toc:
Expand Down

0 comments on commit 6d08df4

Please sign in to comment.