Custom variable problem

I am using the piwik custom variable on a page

I have linked each variable to a specific javascript event

However every event is logged twice or sometimes even more.


on(‘click’,linksport);
on(‘click’,linkNature);

function linksport(){
_paq.push([‘setCustomVariable’,1,‘Link’,‘sports’,‘page’]);
_paq.push([‘trackPageView’]);
{

function linkNature(){
_paq.push([‘setCustomVariable’,2,‘Link’,‘nature’]);
_paq.push([‘trackPageView’]);
}

It seems that when I am using the _paq.push([‘trackPageView’]); , it just aggregating the events rather then pushing them and flushing the queue of events.

Did anyone bump into this problem?

Am I doing something wrong here?

Thanks,