Record Link clicks of AJAX Content

Hello Piwik Gurus,

I am brand new to Piwik. I have a site that dynamically generates content in an area of the page due to AJAX calls. The calls produce links to videos for an intranet training website for my organization. I would like to track the clicks of these videos, however, Piwik doesnt seem to register the clicks. I even tried to force the tracking of these links as Downloads, but that didnt seem to work either. Can someone please tell me, or point me in the direction, how to accomplish this? It is very important to track the clicking of these links, since we are auditing our video library.

Thanks for any assistance.

Try to use an event-listener. The following example works with jQuery and the async tracking-code:


$('.classOfLink').click(function() {
                  _paq.push(["setCustomVariable", 1, 
                             "Click on Video XYZ", 
                             $(this).attr('href'), 
                             "page"]); 
                  _paq.push(["trackPageView"]);
            });

  1. If even the link is generated with ajax, you have to use the jQuery “live”-listener.
  2. This example sets a custom variable. You can alternatively set a custom URL, custom page title, etc. See http://piwik.org/docs/javascript-tracking/