Quantcast
Channel: Piwik Forums - Support & Bugs
Viewing all articles
Browse latest Browse all 4243

Best way to track custom events? (no replies)

$
0
0
Hi, I'm getting familiar with Piwik and how to use it for custom tracking. What I want to do is basically track "usages" or custom log messages:

  • in the tracked pages source code, I'd be calling something like (on demand, even multiple times in single page view)
      _paq.push(["myCategory", "myParameter1", "myParameter2"])  
  • piwik automatically saves these logs to DB
  • in Piwik, I'd have PHP plugin to process and display these data


What is the best way to achieve this? I know Piwik has custom variables but they seem to me too limited for my usecase so I'm trying to find a way how to achieve this using custom PHP plugin. I was trying to find some tutorials/documentation but it shows basic PHP plugin without this custom tracking. When I tried to call the _paq.push as above, I'm getting
Uncaught TypeError: Cannot call method 'apply' of undefined

Right now I have 2 possible solutions:
  • With custom variables, I would probably have to create a "wrapper" JavaScript object that would check custom variables to avoid overriding and if needed it would call _paq.push(['trackPageView']); . I'm only worried about possible high network communication as it is not very efficient
  • Create independent JS logger that would push data to some piwik-independent endpoint. This endpoint would save them to e.g. DB and Piwik PHP plugin would simply read them from DB display them

Neither of them looks like ideal to me...

Viewing all articles
Browse latest Browse all 4243

Trending Articles