forked from harelba/q
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added more stuff from the original site, include GA link conversion, but
not sure it's working yet
- Loading branch information
Showing
5 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
google-site-verification: google0efeb4ff0a886e81.html |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters