How to track clicks on javascript function?


#1

Hi there! Tried everything, but still can’t figure out how to track clicks on a code that I have. The code goes like this:


<script type="text/javascript" charset="UTF-8"> (function(){ document.write("<script src='http://www.grupovo.bg/adpopup.php?refid=104243&webid=83&cid=&size=popup' charset='UTF-8' type='text/javascript'><"+"/script>"); })(); </script>

It’s a code of a affiliate program needed for popup. I want to track the clicks on it, but whatever I try, nothing is counted. Any help/advices?
Thanks!


(vipsoft) #2

After you load the popup, you have to attach a click handler. Something like this in jquery:


var tag = $('div.popup-pop-over a.click');

tag.click(function() {
    piwikTracker.trackLink(tag.attr('href'), 'link');
});


(Matthieu Aubry) #3

Btw if you come up with a easy reusable snippet please let us know and we will add it to doc :slight_smile: