Skip to content

Commit

Permalink
Merge pull request #9 from luniki/feature/configure-tracker-urls
Browse files Browse the repository at this point in the history
Added configuration settings for the URLs of the Matomo trackers.
  • Loading branch information
miesgre committed May 21, 2024
2 parents 4472fe4 + 3fcfde4 commit 0efda07
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,13 @@ Collects the events sent by the `es.upv.paella.userEventTracker` plugin and send
"enabled": false,
"context": [
"userTracking"
],
],
"server": "//matomo.server.com/",
"siteId": "1",
"trackerUrl": {
"php": "matomo.php",
"js": "matomo.js"
},
"matomoGlobalLoaded": false,
"events": {
"category": "PaellaPlayer",
Expand Down
4 changes: 4 additions & 0 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@
],
"server": "//matomo.server.com/",
"siteId": "1",
"trackerUrl": {
"php": "matomo.php",
"js": "matomo.js"
},
"matomoGlobalLoaded": false,
"cookieType": "tracking",
"events": {
Expand Down
8 changes: 6 additions & 2 deletions src/plugins/es.upv.paella.matomo.userTrackingDataPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ export default class MatomoUserTrackingDataPlugin extends DataPlugin {
else {
const server = this.server;
const siteId = this.siteId;
const trackerUrl = {
php: this.config.trackerUrl?.php ?? 'matomo.php',
js: this.config.trackerUrl?.js ?? 'matomo.js'
};
this.player.log.debug("Matomo analytics plugin enabled.");
this.trackCustomDimensions();
const userId = await this.getCurrentUserId();
Expand All @@ -128,10 +132,10 @@ export default class MatomoUserTrackingDataPlugin extends DataPlugin {
_paq.push(['enableLinkTracking']);
(function() {
var u=server;
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setTrackerUrl', u+trackerUrl.php]);
_paq.push(['setSiteId', siteId]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
g.type='text/javascript'; g.async=true; g.src=u+trackerUrl.js; s.parentNode.insertBefore(g,s);
})();
}
// accurately measure the time spent in the visit
Expand Down

0 comments on commit 0efda07

Please sign in to comment.