How To: Piwik and NodeBB
-
Awesome. IIRC my idea for setting up a tutorials category came from your promise to deliver a Piwik tutorial. And you didn't disappoint, great job. Thanks!!
-
Hi there,
Is there any other way to implement piwik other then adding it to the header. I've done it in my setup and it seems to be working but when I compare the internal dashboard with piwik the internal dashboard shows about approx three times more unique visits and page views.
Is there parts of nodebb where the header isn't loaded or other oddity that could explain this.
-
@hmj That discrepancy can likely be explained by Piwik only tracking cold page loads, whereas NodeBB tracks page transitions as well (that is, going between pages).
@rod I see there is code to fire Piwik when a page transition finishes:
$(window).on('action:ajaxify.contentLoaded', function(ev, data) { firePiwik(data); });
Any chance you could test this to ensure that it is actually working?
-
@julian said in How To: Piwik and NodeBB:
@hmj That discrepancy can likely be explained by Piwik only tracking cold page loads, whereas NodeBB tracks page transitions as well (that is, going between pages).
What do you mean by that? In my Piwik I see visitors moving between topics
@rod I see there is code to fire Piwik when a page transition finishes:
$(window).on('action:ajaxify.contentLoaded', function(ev, data) { firePiwik(data); });
Any chance you could test this to ensure that it is actually working?
Yes, I believe this is working. Suggestion on how to test this?
-
@pichalite I am quite sure that Piwik ignores them, installed a plugin to count bots now and I cannot see that it accounts for around 4k unique visits and at least 40k pageviews per day that are not counted in Piwik. I added GA tracking yesterday as well to compare to the two and GA seems to be in line with Piwik.
So I'm a bit baffled by the amount of traffic Nodebb is showing in it's backend.
-
@julian Not sure here is a list of the plugins we are using.
Activated plugins:
nodebb-plugin-composer-default
nodebb-plugin-dbsearch
nodebb-plugin-emoji-extended
nodebb-plugin-emoji-one
nodebb-plugin-markdown
nodebb-plugin-mentions
nodebb-plugin-spam-be-gone
nodebb-plugin-sso-oauth
nodebb-widget-essentialsSo I've added GA to the mix. I did that with adding it in the same custom header as to validate that my Piwik installation is not on the fritz. Comparing the two I see a little fewer unique visits between the two in piwik but almost exactly the same amount of pageviews.
Nodebb is still off by a factor of three in unique visits and around a factor of three to ten in pageviews.
-
@julian We are on 1.6.0 and not Develop.
Our code is almost a carbon copy of the one above in the first post.
<!-- Piwik --> <script type="text/javascript"> var _paq = _paq || []; (function () { var u = "https://our.piwik.com/"; function firePiwik (data) { if (app && app.user && app.user.uid > 0) { _paq.push(['setUserId', app.user.uid.toString()]); _paq.push(['setCustomVariable', 1, "appUserUsername", app.user.username, "visit"]); } _paq.push(['setDocumentTitle', document.title]); _paq.push(['setCustomUrl', location.href]); _paq.push(['enableHeartBeatTimer']); _paq.push(['appendToTrackingUrl', 'bots=1']); if (data.tpl === 'search') { _paq.push(['trackSiteSearch', ajaxify.data.search_query,, ajaxify.data.matchCount]); } else { _paq.push(['trackPageView']); } _paq.push(['enableLinkTracking']); _paq.push(['setTrackerUrl', u+'stats/piwik.php']); _paq.push(['setSiteId', 1]); } 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+'stats/piwik.js'; s.parentNode.insertBefore(g,s); $(window).on('action:ajaxify.contentLoaded', function(ev, data) { firePiwik(data); }); })(); </script> <noscript><p><img src="https://our.piwik.com/stats/piwik.php?idsite=1&rec=1&bots=1" style="border:0;" alt="" /></p></noscript> <!-- End Piwik Code -->