1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00
appwrite/public/scripts/views/analytics/event.js

28 lines
744 B
JavaScript
Raw Normal View History

(function(window) {
"use strict";
2019-05-09 18:54:39 +12:00
window.ls.container.get("view").add({
2021-01-18 19:29:26 +13:00
selector: "data-analytics",
controller: function(element) {
2020-02-04 19:28:41 +13:00
var action = element.getAttribute("data-analytics-event") || "click";
2019-05-09 18:54:39 +12:00
element.addEventListener(action, function() {
var category =
2020-02-04 08:20:10 +13:00
element.getAttribute("data-analytics-category") || "undefined";
var label = element.getAttribute("data-analytics-label") || "undefined";
2019-05-09 18:54:39 +12:00
if (!ga) {
console.error("Google Analytics ga object is not available");
2019-05-09 18:54:39 +12:00
}
ga("send", {
hitType: "event",
eventCategory: category,
eventAction: action,
eventLabel: label
});
});
}
});
})(window);