Example of trackEvent



I am having trouble using the trackEvent method in my javascript. Im using it after piwik tracking script - but im still getting trackEvent is not defined as an error :

var _paq = _paq || [];
(function() {
var u=((“https:” == document.location.protocol) ? “https” : “http”) + “: xxx”;
_paq.push([‘setTrackerUrl’, u+‘piwik.php’]);
_paq.push([‘setSiteId’, 2]);
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);

<img src=xxx?idsite=2" style=“border:0;” alt="" />

trackEvent(x, x, x,x )

Any help is appreceated

(Stefan Giehl) #2

Have a look at the JavaScript Tracking Docu: JavaScript Tracking Client: API Reference - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3
You need to call trackEvent using _paq.push(…).



Do you have any concrete example of what you would track as an event?
That would help in providing you with the right code


I have the same problem,

i want to track a video.

I would like the code which comes into the site and the code that comes after onplay. As i am not the programmer i need an example with correct writing.