Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ module.exports = {
siteId: 'ID',
phpLoader: 'matomo.php',
jsLoader: 'matomo.js',
// optional matomo methods
tracking: [
['enableHeartBeatTimer'],
['setRequestMethod', 'POST']
]
},
},
};
Expand Down
5 changes: 2 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = function (context) {
}
const phpLoader = matomo.phpLoader || 'matomo.php';
const jsLoader = matomo.jsLoader || 'matomo.js';
const tracking = matomo.tracking || [];

const isProd = process.env.NODE_ENV === 'production';

Expand Down Expand Up @@ -46,13 +47,11 @@ module.exports = function (context) {
tagName: 'script',
innerHTML: `
var _paq = window._paq = window._paq || [];
_paq.push(['setRequestMethod', 'POST']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
Comment on lines 50 to 51
Copy link
Copy Markdown

@Dr-Electron Dr-Electron Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, is this PR still in development? I would need this change too.
Also not sure why this shouldn't work or be different from the current state. Maybe the order of the element creates the problem? My guide mentioned that my option should be added at the beginning for example.

So maybe we could make the following changes and add everything to the config? That way everyone can specify the order of elements like this in the config

matomo: {
  matomoUrl: 'https://vega.dev.trackmage.com/',
  siteId: '2',
  phpLoader: 'mm.php',
  jsLoader: 'mjs.php',
  tracking: [
    ['setRequestMethod', 'POST'],
    ['trackPageView'],
    ['enableLinkTracking']
    ['enableHeartBeatTimer'],
  ]
},
Suggested change
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);

_paq.push(['enableHeartBeatTimer']);
${tracking.map(x => `_paq.push(${JSON.stringify(x)})`).join(';')};
(function() {
var u="${matomoUrl}";
_paq.push(['setRequestMethod', 'POST']);
_paq.push(['setTrackerUrl', u+'${phpLoader}']);
_paq.push(['setSiteId', '${siteId}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
Expand Down