2019-12-09 14:23:33 +01:00
|
|
|
// Add Google Analytics Event Tracking to resource download links.
|
2021-09-22 13:34:14 +02:00
|
|
|
ckan.module("google-analytics", function(jQuery, _) {
|
2022-05-06 16:29:58 +02:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
return {
|
|
|
|
options: {
|
|
|
|
googleanalytics_resource_prefix: ""
|
|
|
|
},
|
|
|
|
initialize: function() {
|
|
|
|
jQuery("a.resource-url-analytics").on("click", function() {
|
|
|
|
|
|
|
|
var resource_url = encodeURIComponent(jQuery(this).prop("href"));
|
|
|
|
if (resource_url) {
|
|
|
|
ga("send", "event", "Resource", "Download", resource_url);
|
|
|
|
}
|
|
|
|
});
|
2019-12-09 14:23:33 +01:00
|
|
|
}
|
2022-05-06 16:29:58 +02:00
|
|
|
};
|
2019-12-09 14:23:33 +01:00
|
|
|
});
|