Recalculate page property for each event.

Mark H. Wilkinson committed Jun 17, 2015
commit fc633545d8a5e027c728d68529f6350d6541e20f
Showing 1 changed file with 6 additions and 3 deletions
vendor/assets/javascripts/ahoy.js +6 -3
@@ @@ -20,7 +20,6 @@
var queue = [];
var canStringify = typeof(JSON) !== "undefined" && typeof(JSON.stringify) !== "undefined";
var eventQueue = [];
- var page = ahoy.page || window.location.pathname;
var visitsUrl = ahoy.visitsUrl || "/ahoy/visits"
var eventsUrl = ahoy.eventsUrl || "/ahoy/events"
@@ @@ -123,13 +122,17 @@
});
}
+ function page() {
+ return ahoy.page || window.location.pathname;
+ }
+
function eventProperties(e) {
var $target = $(e.currentTarget);
return {
tag: $target.get(0).tagName.toLowerCase(),
id: $target.attr("id"),
"class": $target.attr("class"),
- page: page,
+ page: page(),
section: $target.closest("*[data-section]").data("section")
};
}
@@ @@ -234,7 +237,7 @@
var properties = {
url: window.location.href,
title: document.title,
- page: page
+ page: page()
};
ahoy.track("$view", properties);
};