Incorporating piwik into a Titamium mobile application


#1

Hi all,
I just today began investigating how to use piwik for my client. I’ve read the docs, the faq, the forum posts, etc. But, I’ve seen only one post regarding incorporating piwik with the Titanium Mobile SDK. I know the piwik mobile app is built on Titanium, so I was hoping that I could get some guidance and/or sample code of how I set it up in my project.

Here are my specs:
SDK: Titanium SDK: 3.1.3.GA
Target platform: iOS version 7.0

I’m using the Alloy framework, so is it possible to export the piwik.js file as a CommonJS module, then add a statement in the xml pages? Or if there’s a simpler/more efficient way, I’d be willing to try that. I have no idea at this point of how to start.

Your kind assistance would be most appreciated.

EDIT: If anyone has an open-source mobile project incorporating the tracking api, please post links to it. I really need an example of how it’s used in a mobile app.


#2

Hi,

porting the Piwik.js to Titanium is more or less done. You can see the it in the Piwik Mobile 2 repository:

The tracker.js implements the same or similar tracking methods. The queue is there to decide when to actually send the tracking request. For instance sending a request only every 2 seconds. Could be also used to store tracking requests when there is no internet or if battery is almost empty and perform them later automatically once it is possible. TrackerRequest + HttpRequest executes the actual request and handles all the HTTP communication.

It would be possible to build a Common JS module for that or even an Alloy widget but unfortunately I do not have the time for this at the moment. Basically that means

  • Use dependency injection for HttpRequest to allow the usage of a different HttpRequest class (you do not really want to use our HttpRequest) or just use the default Titanium implementation or another lib
  • Remove our Alloy Settings Controller dependency
  • Dependency injection for config

#3

[quote=thomas-piwik]

The tracker.js implements the same or similar tracking methods. The queue is there to decide when to actually send the tracking request. For instance sending a request only every 2 seconds. Could be also used to store tracking requests when there is no internet or if battery is almost empty and perform them later automatically once it is possible. TrackerRequest + HttpRequest executes the actual request and handles all the HTTP communication.

Basically that means

  • Use dependency injection for HttpRequest to allow the usage of a different HttpRequest class (you do not really want to use our HttpRequest) or just use the default Titanium implementation or another lib
  • Remove our Alloy Settings Controller dependency
  • Dependency injection for config[/quote]

Sorry, but I’m not well-versed enough in either piwik or Titanium to understand what you wrote. I need more basic and detailed information on how to use piwik. I’ve sent a couple of emails to your Piwik Professional Services. I have not received a reply. I need someone to contact me asap to get me started.


#4

Add the /lib/Piwik folder from the mobile2 app found on github. Tried to add the dependency two different ways in the config.json file


"dependencies": {
    	"Piwik": "1.0"
    }

because this is the folder name, and when that failed


"dependencies": {
    	"org.piwik.mobile2": "1.0"
    }

because the dependency usually has a reverse domain name. Neither worked. Each time it threw a compiler error.


[ERROR] :  : Cannot read property 'manifest' of undefined
[ERROR] :  Alloy compiler failed

What is the proper name of the dependency?


#5

Piwik Mobile is not a widget or something similar that you can define as a dependency. You have to download the files and copy the ones you need into your project (see previous comment which files you need).


#6

I’m sorry, but that’s not the type of help I need. Just “copying the ones I need” doesn’t work. If you don’t have the time or inclination to help me achieve my goal, then please say so. You know your product. I don’t. I tried to contact your professional services for help, but haven’t been contacted in return.

Here’s your opportunity to turn around a disgruntled potential customer. It’s up to you to decide if that’s important to you.


#7

Hi mjstelly,

I wrote already in my first response that I do not have the time for this at the moment, unfortunately. Please keep in mind: I am building the mobile app including the tracker in my free time for already 3-4 years. The app is available for free and the source is open. Because I don’t have the time for this at the moment I wanted to give you some hints at least.


#8

I understand. Thank you for your responses. I’ll try to modify it for my needs.


#9

Hi.

I’ve put together a module with the code of the app following the above description.

https://github.com/manumaticx/ti.piwik

I would be glad if Thomas could review and give his blessings to it. It also needs to be tested. For now I was able to track Windows, PageViews and Events tested on an Android device. This works fine for me. I’ve open sourced it so everybody is welcome to contribute and make it better.

Best,
Manuel


#10

Wow, it looks good! I feel a bit sorry there were so many dependencies and no tests. There are probably a few lines that are no longer needed when using it only for tracking but I think not many so not really worth looking for them. I’ll ask to add a link here: Integrations - Analytics Platform - Matomo . Maybe we could also feature a small blog post one day or mention new integrations in Changelogs etc.

At the moment I am not working a lot on the Piwik Mobile 2 app but once I spend more them on it again I’d love to look for a way to integrate it into Piwik Mobile


(Matthieu Aubry) #11

Hi Manuel, your tool looks great! Thanks for sharing it with the community :slight_smile: we’ll be happy to also publish a blog post about it if you are interested ? Keep up the good work!