Improve click analytics

This commit is contained in:
Liam Cardenas 2017-12-18 22:34:03 -08:00
parent f407cd91a1
commit a9863b9082
2 changed files with 4 additions and 1 deletions

View file

@ -46,6 +46,7 @@ export const Header = props => {
onClick={() => navigate("/subscriptions")}
button="alt button--flat"
icon="icon-at"
title={__("My Subscriptions")}
/>
</div>
<div className="header__item header__item--wunderbar">

View file

@ -73,7 +73,8 @@ document.addEventListener("click", event => {
if (target.matches("a") || target.matches("button")) {
// TODO: Look into using accessiblity labels (this would also make the app more accessible)
let hrefParts = window.location.href.split("#");
let element = target.title || (target.text && target.text.trim());
let element =
target.title || (target.textContent && target.textContent.trim());
if (element) {
amplitude.getInstance().logEvent("CLICK", {
target: element,
@ -84,6 +85,7 @@ document.addEventListener("click", event => {
amplitude.getInstance().logEvent("UNMARKED_CLICK", {
location:
hrefParts.length > 1 ? hrefParts[hrefParts.length - 1] : "/",
source: target.outerHTML,
});
}
}