1
0
Fork 0
mirror of synced 2024-07-06 23:21:05 +12:00
appwrite/public/scripts/views/analytics/event.js

28 lines
739 B
JavaScript
Raw Normal View History

(function(window) {
"use strict";
2019-05-09 18:54:39 +12:00
window.ls.container.get("view").add({
selector: "data-analytics-event",
controller: function(element) {
var action = element.getAttribute("data-event-action") || "click";
2019-05-09 18:54:39 +12:00
element.addEventListener(action, function() {
var category =
element.getAttribute("data-event-category") || "undefined";
var label = element.getAttribute("data-event-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);