trackEvent not working on chrome

Hello everybody ,

I am using piwik to track some events on my website .

i used to track click on links so i added something like this :

<a href="LInkHere" onClick="javascript:pushToPaqService('Service', 'LINK');">the link</a>

The script looks like that :

<script>
    function pushToPaqService(name,value){
    _paq.push(['trackEvent', name,value]);
    }
</script>

Its working on FireFox and all events are tracked , but i still getting no information when i use Chrome .

I dont have any errors in my logs/console .

The DoNotTrack is desabled .

I dont have any ip excusion .

Any idea about that please :).

Thanks

Hi @Bocasi
onclick shouldn’t need a javacript: part, but only the function. So you should be able to write

<a href="LInkHere" onclick="pushToPaqService('Service', 'LINK');">the link</a>

I am not sure if this is the cause of your problem.

Hi @Findus23

Thank you for the reply .

I dont think that this is the cause .

I used to change the script and i used also to use javascript .

The function pushToPaqService is executed successfully , but i dont see results on my dashboard .

Then can you check if a http request is sent when the javascript is executed.

It should look similar to
https://piwik.example/piwik.php?e_c=Contactform&e_a=toogle&e_n=close&idsite=4&rec=1&r=485460&h=14&m=33&s=41&url=https://website.example/&_id=e51196b7f63b0853&_idts=1495456419&_idvc=1&_idn=0&_refts=0&_viewts=1495456419&send_image=1&pdf=1&qt=0&realp=0&wma=0&dir=0&fla=0&java=0&gears=0&ag=0&cookie=1&res=1920x1080&gt_ms=22&pv_id=nDtVPU

i found that the http request wasn’t sent .

Only in Chrome or also in other browsers?

At least this means that the piwik server backend isn’t at fault.

Anothing you can test: Add an link with “#” as href: <a href="#" onclick="pushToPaqService('Service', 'LINK');">the link</a>

Maybe the function doesn’t get executed correctly as the browser has already left the page before the request can be made.

Its solved ,

It was only on Chrome , i deleted all cookies and cash from chrome, i disactivated a proxy that existed , an i found that in some elements i used onclick not onClick .

Thank you for your help @Findus23 .