1
0
Fork 0
mirror of synced 2024-07-04 06:00:53 +12:00
appwrite/public/scripts/views/analytics/event.js
2019-09-13 13:47:07 +03:00

28 lines
739 B
JavaScript

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