Skip to content

Commit 7358c32

Browse files
committed
Added phpLoader and jsLoader
1 parent 2629922 commit 7358c32

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ module.exports = {
1414
matomo: {
1515
matomoUrl: 'https://your.matomo.instance/',
1616
siteId: 'ID',
17+
phpLoader: 'matomo.php',
18+
jsLoader: 'matomo.js',
1719
},
1820
},
1921
};

src/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ module.exports = function (context) {
1717
if (!siteId) {
1818
throw new Error('Please specify the `siteId` field in the `themeConfig.matomo`');
1919
}
20+
const phpLoader = matomo.phpLoader || 'matomo.php';
21+
const jsLoader = matomo.jsLoader || 'matomo.js';
2022

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

@@ -44,14 +46,17 @@ module.exports = function (context) {
4446
tagName: 'script',
4547
innerHTML: `
4648
var _paq = window._paq = window._paq || [];
49+
_paq.push(['setRequestMethod', 'POST']);
4750
_paq.push(['trackPageView']);
4851
_paq.push(['enableLinkTracking']);
52+
_paq.push(['enableHeartBeatTimer']);
4953
(function() {
5054
var u="${matomoUrl}";
51-
_paq.push(['setTrackerUrl', u+'matomo.php']);
55+
_paq.push(['setRequestMethod', 'POST']);
56+
_paq.push(['setTrackerUrl', u+'${phpLoader}']);
5257
_paq.push(['setSiteId', '${siteId}']);
5358
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
54-
g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
59+
g.type='text/javascript'; g.async=true; g.src=u+'${jsLoader}'; s.parentNode.insertBefore(g,s);
5560
})();
5661
`,
5762
},

0 commit comments

Comments
 (0)