Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analytics plugin not sending info #11

Open
nbartley opened this issue Jun 12, 2017 · 13 comments
Open

Analytics plugin not sending info #11

nbartley opened this issue Jun 12, 2017 · 13 comments

Comments

@nbartley
Copy link

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.

@bmbrands
Copy link
Owner

Is your Moodle install publicly available so I can have a look?

@bmbrands
Copy link
Owner

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

@nbartley
Copy link
Author

nbartley commented Jun 13, 2017 via email

@jobcespedes
Copy link

jobcespedes commented Jul 17, 2017

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 -->```

@bmbrands
Copy link
Owner

Thanks for your feedback. I don't know what the issue is yet. I will do more digging soon.

@jobcespedes
Copy link

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.

@jacac
Copy link

jacac commented Sep 18, 2017

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.

@lucaboesch
Copy link

Good point.
I had to switch to fallback ‚additionalhtmlfooter‘, too.

@erazorbg
Copy link

erazorbg commented Oct 30, 2017

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 || [];

@guyheli
Copy link

guyheli commented Nov 6, 2017

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 :)

@guyheli
Copy link

guyheli commented Nov 6, 2017

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)]

@sgorange
Copy link

sgorange commented Nov 9, 2017

The UserId has to be a string I think. adding single quotes (') in mustache template :
_paq.push(['setUserId', '{{{userid}}}']);
worked for me

@scara
Copy link

scara commented Nov 9, 2017

Good point @sgorange 😉.
Anyone has already planned to review and promote #12 including #11 (comment)? Pinging also @jobcespedes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants