piwik tracker config option

This commit is contained in:
Evert Prants 2017-08-31 15:32:00 +03:00
parent a2bea009a2
commit 4e2fd77e9c
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
2 changed files with 18 additions and 0 deletions

View File

@ -51,6 +51,11 @@ app.use((req, res, next) => {
csrf: req.session.csrf csrf: req.session.csrf
}) })
// Add Piwik tracker if configured
if (config.piwik && config.piwik.site_id) {
res.locals.piwik = config.piwik
}
next() next()
}) })

View File

@ -3,6 +3,19 @@ html
head head
meta(charset="utf8") meta(charset="utf8")
meta(name="viewport", content="width=device-width, initial-scale=1") meta(name="viewport", content="width=device-width, initial-scale=1")
if piwik
script(type="text/javascript").
var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="#{piwik.track_url}";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '#{piwik.site_id}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
block links block links
link(rel="stylesheet", type="text/css", href="/style/main.css") link(rel="stylesheet", type="text/css", href="/style/main.css")
link(rel="stylesheet", type="text/css", href="/style/footer.css") link(rel="stylesheet", type="text/css", href="/style/footer.css")