Using Piwik with DurandalJS

I’d like to add a Piwik code inside my Durandal JS SPA, but I can’t find a way to properly implement it.

This is this code on index.html. It only loads once when the SPA is loaded.


<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://piwik.example.com/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', 5]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
    g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<noscript><p><img src="http://piwik.example.com/piwik.php?idsite=5" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->

Then in the main shell.js, whenever I navigate between pages:


router.on('router:navigation:complete', function() {
  _paq.push(['trackPageView']);
});

This approach adds each visit to Piwik on navigation:complete, but it’s not specifying the page url. Each visit is attributed to the home page.

Is there a way to set the page url before firing trackPageView?