From f675c5c6245e6f1329b0846152f156788a69ea5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mierzwa?= Date: Thu, 1 Nov 2018 19:48:16 +0000 Subject: [PATCH] chore(demo): update demo analytics code --- demo/custom.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/demo/custom.js b/demo/custom.js index d764ca96f..085d3905c 100644 --- a/demo/custom.js +++ b/demo/custom.js @@ -21,3 +21,26 @@ ga("create", "UA-128338979-1", "auto"); ga("send", "pageview"); + +function getSearch() { + return window.location.search; +} + +let search = getSearch(); + +function updateSearch() { + let newSearch = getSearch(); + if (newSearch !== search) { + search = newSearch; + ga("set", "page", window.location.pathname + window.location.search); + } +} + +setInterval(function() { + updateSearch(); + ga("send", { + hitType: "event", + eventCategory: "heartbeat", + eventAction: "ping" + }); +}, 15 * 1000);