Skip to content

Commit

Permalink
feat(matomo): it's now possible to define the file names
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarbeau committed Oct 2, 2019
1 parent af5058d commit a85281c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/lib/analytics/shared/analytics.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})();
}
Expand Down

0 comments on commit a85281c

Please sign in to comment.