I have a angularjs SPA and want to track page views with piwik. I have the following setup:
index.html:
<html>
...
<body>
<piwik site-id="{{settings.PiwikSiteId}}"></piwik>
...
<script type="text/javascript" src="//analytics.myserver.net/piwik.js"></script>
<script type="text/javascript" src="/scripts/dist/common.js"></script> <!-- includes app bootstrapping and directive -->
</body>
</html>
piwik directive:
var _paq = _paq || [];
app.directive('piwik',
function() {
return {
restrict: 'E',
scope: {
siteId: '@'
},
controller: ['$scope', '$window', function($scope, $window) {
var piwikTrackingApiUrl = 'https://analytics.myserver.net/piwik.php';
_paq.push(['setTrackerUrl', piwikTrackingApiUrl]);
_paq.push(['setSiteId', $scope.siteId]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
}]
}
});
app.js
var app = angular.module('ncApp', ['infinite-scroll', 'ngRoute', ..., 'angulartics', 'angulartics.piwik', ...]);
In the debugger I can see _paq being filled, but there is no request to https://analytics.myserver.net/piwik.php