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:
[ul]
[li] in the tracked pages source code, I’d be calling something like (on demand, even multiple times in single page view)
[/li]_paq.push(["myCategory", "myParameter1", "myParameter2"])
[li] piwik automatically saves these logs to DB
[/li][li] in Piwik, I’d have PHP plugin to process and display these data
[/li][/ul]
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:
[ul]
[li] 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
[/li][li] 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
[/li][/ul]
Neither of them looks like ideal to me…