From a85281cec4e1270f13454b2cc5a8b3d404f46216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Barbeau?= Date: Wed, 2 Oct 2019 14:49:08 -0400 Subject: [PATCH] feat(matomo): it's now possible to define the file names --- .../core/src/lib/analytics/shared/analytics.service.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/core/src/lib/analytics/shared/analytics.service.ts b/packages/core/src/lib/analytics/shared/analytics.service.ts index 791d0bebbd..b90a4cf8e8 100644 --- a/packages/core/src/lib/analytics/shared/analytics.service.ts +++ b/packages/core/src/lib/analytics/shared/analytics.service.ts @@ -22,20 +22,24 @@ export class AnalyticsService { if (!this.options.url || !this.options.id) { return; } + const url = + this.options.url.substr(-1) === '/' + ? this.options.url + 'matomo' + : this.options.url; (window as any)._paq = (window as any)._paq || []; const paq: any = (window as any)._paq; paq.push(['trackPageView']); paq.push(['enableLinkTracking']); (() => { - paq.push(['setTrackerUrl', this.options.url + 'matomo.php']); + paq.push(['setTrackerUrl', url + '.php']); paq.push(['setSiteId', this.options.id]); const g = document.createElement('script'); const s = document.getElementsByTagName('script')[0]; g.type = 'text/javascript'; g.async = true; g.defer = true; - g.src = this.options.url + 'matomo.js'; + g.src = url + '.js'; s.parentNode.insertBefore(g, s); })(); }