2

I want to use Piwik to trace which user stays on which page in my rails app but I cannot figure out how to trace it. I added a custom variable (page scope) but in Piwik I only see the user_id and its count of visits but not which pages. Also, I got url based view but not for which user. Anybody knows how to deal with this? Also I can not use custom Dimension because my Piwik version is older and I can not upgrade it now. I tried setUserId option as well but no luck.

My code :

<script type="text/javascript">

  var _paq = _paq || [];
  _paq.push(['setCustomVariable', 1, "user_id", "<%= current_user.id %>", "page" ]);
  _paq.push(['setUserId', '<%= current_user.id %>']);
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  _paq.push(['enableHeartBeatTimer']);

  (function() {
    var u="//myserver/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);
  })();
</script>
<noscript><p><img src="//myserver/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
3
  • So the custom variable with scope page does not appear in the tooltip when you hover on the page URL or page title in Piwik's visitor log as explained at piwik.org/docs/custom-variables? Have you checked what's inside the database?
    – André
    Mar 28, 2016 at 20:44
  • I can see but I not getting how to fetch data through ajax request: which user visits which pages and for how long. Also I tried with setUserId. Is there any linking in userId and visitorId? I can access data through method Live.getVisitorProfile
    – Guru
    Mar 29, 2016 at 6:12
  • Use a browsers developers tools to view the HTTP requests set to Piwik, and what is being sent?
    – Tim Child
    Mar 31, 2016 at 18:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.