Creating a one-page / thick client application, and I wonder what is best used to enable and track using http://piwik.org/ p>
I would like to use Piwik in such a way that it is architecturally robust and replaced with another library in the future.
There seem to be two main tracking options with Piwik:
- Fill the global
_paq array with commands, then load the script (I donβt understand how to write future "pages" or change variables, though) - Get and use
var myTracker = Piwik.getTracker()
_paq approach:
myApp.loadAnalytics = function() { } myApp.track = function(pageName) { window._paq = window._paq || []; _paq.push(['setDocumentTitle', pageName]); _paq.push(["trackPageView"]); } myApp.loadAnalytics()
.getTracker() :
myApp.loadAnalytics = function() { } myApp.track = function(pageName) { myApp.tracker = myApp.tracker || Piwik.getTracker('https://mysite.com', 1); myApp.tracker.trackPageView(pageName); } myApp.loadAnalytics()
Are these approaches functionally identical? Is it preferable for another for a single page application?
Simplgy
source share