1
0
Fork 0
mirror of synced 2024-05-19 12:12:36 +12:00
appwrite/public/scripts/views/analytics/event.js
2021-01-18 08:29:26 +02:00

28 lines
744 B
JavaScript

(function(window) {
"use strict";
window.ls.container.get("view").add({
selector: "data-analytics",
controller: function(element) {
var action = element.getAttribute("data-analytics-event") || "click";
element.addEventListener(action, function() {
var category =
element.getAttribute("data-analytics-category") || "undefined";
var label = element.getAttribute("data-analytics-label") || "undefined";
if (!ga) {
console.error("Google Analytics ga object is not available");
}
ga("send", {
hitType: "event",
eventCategory: category,
eventAction: action,
eventLabel: label
});
});
}
});
})(window);