mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-28 05:54:48 -04:00
Update piwik-analytics code.
This commit is contained in:
parent
b7f25c45f2
commit
f0bee58869
2 changed files with 15 additions and 5 deletions
|
@ -17,17 +17,27 @@ const init = () => {
|
|||
// reference: http://piwik.org/docs/javascript-tracking/
|
||||
|
||||
const pkBaseURL = (win.location.protocol === 'https:' ? 'https://' : 'http://') + settings.baseURL + '/';
|
||||
const queue = [];
|
||||
let piwikTracker = null;
|
||||
|
||||
dom('<script></script>').attr('src', pkBaseURL + 'piwik.js').appTo('body');
|
||||
onLoad(() => {
|
||||
piwikTracker = win.Piwik.getTracker(pkBaseURL + 'piwik.php', settings.idSite);
|
||||
piwikTracker.enableLinkTracking();
|
||||
piwikTracker = win.Piwik && win.Piwik.getTracker(pkBaseURL + 'piwik.php', settings.idSite);
|
||||
if (piwikTracker) {
|
||||
piwikTracker.enableLinkTracking();
|
||||
while (queue.length) {
|
||||
piwikTracker.trackPageView(queue.shift());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
event.sub('location.changed', item => {
|
||||
const title = item.getCrumb().map(i => i.label).join(' > ');
|
||||
piwikTracker.trackPageView(title);
|
||||
if (piwikTracker) {
|
||||
piwikTracker.trackPageView(title);
|
||||
} else {
|
||||
queue.push(title);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ const addTest = (label, info, passed, result) => {
|
|||
const $test = dom(testTpl).appTo('#tests');
|
||||
$test.find('.label').text(label);
|
||||
$test.find('.result')
|
||||
.addCls(passed ? 'passed' : 'failed')
|
||||
.text(result ? result : passed ? 'yes' : 'no');
|
||||
.addCls(passed ? 'passed' : 'failed')
|
||||
.text(result ? result : passed ? 'yes' : 'no');
|
||||
$test.find('.info').html(info);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue