From 89df55c33f8b0d93d8390b20b9a39ea43e12b915 Mon Sep 17 00:00:00 2001 From: ruKurz Date: Sun, 11 Jun 2017 16:02:10 +0200 Subject: [PATCH] #15 - Add advanced configuration options for piwik analytics. --- packages/rocketchat-analytics/client/trackEvents.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/rocketchat-analytics/client/trackEvents.js b/packages/rocketchat-analytics/client/trackEvents.js index b7f01b725227..af3d4c8b6f54 100644 --- a/packages/rocketchat-analytics/client/trackEvents.js +++ b/packages/rocketchat-analytics/client/trackEvents.js @@ -13,7 +13,12 @@ if (!window._paq || window.ga) { if (window._paq) { const http = location.protocol; const slashes = http.concat('//'); - const host = slashes.concat(window.location.hostname); + let host = slashes.concat(window.location.hostname); + if (RocketChat.settings.get('PiwikAnalytics_cookieDomain')) { + let parts = window.location.hostname.split('.');parts.shift(); + let subDomains = parts.join('.'); + host = slashes.concat(subDomains); + } window._paq.push(['setCustomUrl', host + route.path]); window._paq.push(['trackPageView']); }