Parsing .xml log and feed into Piwik


#1

Hello All,
I have offline App that generate .xml file. I Parsed it and have a JSON now I want to feed into Piwik.
There are pages and event attributes in the log and I want for each page or job or event I run piwik. I am thinking about Php or JS tracker.
Here is the sample of JSON that I want to feed into Piwik. Thanks for helping me.
[
{
“Job”: [
{
"$": {
“name”: “0010002000256”,
“guid”: “e7d7b733-771b-464f-9632-8892f145e54a”,
“start”: “2014-08-26T21:05:58.6711509-04:00”,
“end”: “2014-08-27T10:23:31.7363175-04:00”
},
“Pages”: [
{
“Page”: [
{
"$": {
“name”: “ThemeC\AttractionScreen.xaml”,
“start”: “2014-08-26T21:05:58.6731511-04:00”,
“end”: “2014-08-27T10:18:43.5843175-04:00”
},
“Events”: [
{
“Event”: [
{
"$": {
“type”: “Button”,
“occurrence”: “2014-08-27T10:18:43.5263175-04:00”,
“id”: “ScreenSaverMoveForwardButton”,
“action”: “Button Click on screensaver”
}
}
]
}
]
},


(Matthieu Aubry) #2

Someone added support for JSON parsing in Add JsonFormat to handle json logs without regex parsing. by gregorg · Pull Request #120 · matomo-org/matomo · GitHub

Maybe this could be extended?


#3

What exactly do you want to achieve? Should this be tracked as pages and events? What about the Jobs? As what should they be imported? So far I reckon using the PHP tracker would be simplest solution for you


#4

I want for each job and each page. I call piwik.php but I dont know where to start and how to make request because I am working in node.js I parsed the .xml file and make the JSON and now I want to pass it to piwik as if they are true web pages and I add the PIwik.js code to my page.

Now I am looking to make my .xml file to DoM objects and do Jquery on that and call piwik.js for each page that I parse. But if you know the simpler way specially piwik.php please help me since I am new to php.


#5

Thank you so much Thomas I looked at the PIwiktracker.php the only thing that I don’t know is what should I put for setUrl($url=’ ') since I am working offline and those pages are not actually web pages if I pass the page as it is for example: ThemeC\AttractionScreen.xaml you think it is gonna work?


#6

You could prepend any fake domain like “http://www.example.org/ThemeC\AttractionScreen.xaml” or maybe you can convert it to a path completely like “http://www.example.org/ThemeC/AttractionScreen.xaml”. You’d probably have to create a website in Piwik anyway. Just use the same domain as used there. We are doing something similar in our mobile app.


#7

Thanks a lot Thomas I finally made it work I hope I can participate in developing of this project its wonderful software. you guys did a great job.


#8

Thx and you’re very welcome to participate!