0
votes

I've got a problem. I want to track the users of my mobile Web App with Piwik, but because of AJAX only the views on the first page are tracked. So I tried to use the pageinit function to load the Piwik tracking script on every page. But this also fails (Piwik also only tracks the first page). I have bound in the script in the -section. What I am doing wrong?

<script type="text/javascript">
$(#ac).on('pageinit', function(){
var _paq = _paq || [];
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);

(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://url/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.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
});
</script>
<!-- End Piwik Code -->
1

1 Answers

0
votes

Once you have loaded the script, you can use the Piwik API for the tracking inside the page events of Jquery Mobile. For example, to load a page (it will appear under" Actions->Pagea titles" of Piwik):

$(document).on( 'pageinit','#YOUR_PAGE_ID',function( event ) { 
    _paq.push(['trackPageView', 'THE_TITLE_YOU_WANT_FOR_YOUR_PAGE']);       
});