Commit 7d810238 authored by Jim Tittsler's avatar Jim Tittsler

WP: use oeru_analytics shortcode for tracking

parent a32dfbce
......@@ -84,6 +84,10 @@ if (opt['--options']) {
}
});
}
// move the old --siteid option into the new options map
if (opt['--siteid']) {
options.siteid = opt['--siteid'];
}
console.log(JSON.stringify(options, null, 2));
if (opt['--wpurl']) {
wp = wordpress.createClient({
......@@ -457,23 +461,13 @@ function processPage(pi) {
theme.process($, opt);
// if using Piwik, install it at the bottom of the page
if (opt['--siteid']) {
$('body').append(`
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//stats.oeru.org/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', ${opt['--siteid']}]);
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);
})();
</script>
<noscript><p><img src="//stats.oeru.org/piwik.php?idsite=${opt['--siteid']}" style="border:0;" alt="" /></p></noscript>
`);
// if using analytics, install at the bottom of the page
if (options.siteid) {
options.tracker = options.tracker || "//stats.oeru.org";
$('#content').append(`[oeru_analytics type="piwik" url="${options.tracker}" id="${options.siteid}"]`);
}
if (options.google_analytics) {
$('#content').append(`[oeru_analytics type="google" id="${options.google_analytics}"]`);
}
// save the page: to Wordpress or to filesystem
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment