Open nbartley opened 7 years ago
Is your Moodle install publicly available so I can have a look?
Could you try updated to the latest version and see if there is still an issue? I have just pushed an update to Moodle.org
Apologies, just updated and still no good unfortunately.
On Tue, Jun 13, 2017 at 11:34 PM, Bas Brands notifications@github.com wrote:
Could you try updated to the latest version and see if there is still an issue? I have just pushed an update to Moodle.org
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bmbrands/moodle-local_analytics/issues/11#issuecomment-308136505, or mute the thread https://github.com/notifications/unsubscribe-auth/ANggO6XP-WEfR_NW4X0Jpeb9SfX2ulqeks5sDp35gaJpZM4N241B .
Same thing here. I tried with piwik autogenerated code and it works. With the plugin code, it doesn't:
<!-- Piwik / working -->
var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//portafoliovirtual.ucr.ac.cr/piwik/";
_paq.push(['setTrackerUrl', u+'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+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
<!-- End Piwik Code -->
<!-- moodle-local_analytics / not working -->
var _paq = _paq || [];
_paq.push(['setDocumentTitle', 'Área de Ciencias Sociales/Facultad de Ciencias Sociales/Escuela de Trabajo Social/I - S - 2017 - RRF - Ideología Ética y Derechos Humanos II - 003/Ver']);
_paq.push(['setUserId', 10030]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
_paq.push(['enableHeartBeatTimer', 30]);
(function() {
var u='//portafoliovirtual.ucr.ac.cr/piwik/';
_paq.push(['setTrackerUrl', u+'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+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
<!-- End moodle-local_analytics Code -->```
Thanks for your feedback. I don't know what the issue is yet. I will do more digging soon.
Thanks, I'm in Moodle 3.1.5+.
I did another test using the same code generated by the plugin, but injecting it manually in 'additionalhtmlhead'. That way, it works.
I'll continue testing.
The issue is that Moodle inserts the code inside the require(['core/first'], function() {
. This makes the _paq variable local and not accessible for the piwik code.
Good point. I had to switch to fallback ‚additionalhtmlfooter‘, too.
A quick workaround for this issue is to make the _paq variable global.
In my tests this fixed the issue:
replace var _paq = _paq || [];
with window._paq = window._paq || [];
Thank you erazorbg - this did fix the issue (mostly). Hits and DocumentTitle are now reported, but UserId and the User Report still sadly not... The Page source code does reflect the UserId, but it does not find its way to Piwik. Any ideas on what could be causing this - hopefully I've missed something obvious :)
Applied the patches found here https://github.com/bmbrands/moodle-local_analytics/pull/12/files they also make the plugin start reporting data - but UserId still not recorded although it reflects in the page source.
[Moodle 3.3, local_analytics | 1.5 (Build: 2017061300)]
The UserId has to be a string I think. adding single quotes (') in mustache template :
_paq.push(['setUserId', '{{{userid}}}']);
worked for me
Good point @sgorange 😉. Anyone has already planned to review and promote #12 including https://github.com/bmbrands/moodle-local_analytics/issues/11#issuecomment-343179607? Pinging also @jobcespedes.
Good day,
Moodle 3.2.3, local_analytics 1.5 20170313
I configured the plugin, set the host name. When inspecting the site, it shows it is loading the piwik.js from the correct server. However, no data was being recorded. Verified in both boost theme and adaptable, no data.
Switch to adaptable analytics with the same settings, data being transmitted correctly.
I have turned on debugging in piwik and logged everything. There seem to be no requests to the tracker api from the local plugin. When I inspect the source code on the site, everything appears correct.