Updating a hard-coded customized Piwik


#1

Hello,
I have a suggestion, or rather a question: how can I update Piwik without losing all the customization i made? For sure I am not the only one in this situation.

For instance, after any update I need to re-do all the files i modified. In my case it is about the live plugin (i have a custom controller.php because i want the visitors of “today” starting with midnight like google analytics, not last 24 hours; i have custom images for my pages; and i have a custom getLastVisitsStart.twig with lots of modifications).

Is there any way to update Piwik without worrying about this? Most of the times i manually compare my custom template with fresh-installed one and add/modify the lines. But I have come to the conclusion that these particularly files i talk about rarely modify in core, if at all. Maybe dont try to upload a new file on server if it was not modified between piwik versions? Is there a way to do that in my end? Same goes for the images.

I tried removing writing permission on the live plugin folder on my server, but it is not working, it resets itself to 777.


(Matthieu Aubry) #2

Hi there,

Thanks for asking. the official way to do modifications to Piwik is create a custom plugin. With plugins, you can actually anything you want, even replace content in other plugins and more. It’s very modular and powerful, but it can be a bit complicated to do it if you’re not a developer. Maybe some of your changes would make sense to be put into core directly? could you list all changes you make and how they are useful and maybe we could move some of them in core?


#3

Thx for reply… yeah, unfortunately i am not a developer… yet, i managed to do what i need, google was my friend :slight_smile:

I think that most of my changes are only suitable for a small site… but let`s see

  1. While waiting for the real-time pinging for accurate time on page feature I have in the meantime some sort of “active right-now” visual aid by having different colors for “active” browsing sessions and “old” ones. Created a conditional “if last action is newer than 300 seconds, then apply this css”, eg, a dark green background. Again, this is only suitable if you have like in my case 1 visit every 5-10 minutes or so, on a small site… otherwise all of them would be green. Also, I modified the clock css (it was too hard for me to read and distinguish it) and other small things which are rather a matter of personal taste, not suitable for core modification…

  2. added visitID and also userID (in case it is set)… i believe these are important, and i also use them for distinguishing between actions via the real-time web-desktop notification php script i have.Without visistID it would be hard to distinguish between those notifications that pop-up in the corner, who is doing what.

  3. I could never get used with counting visits and actions for “last 24 hours” so i added a function of “today” in plugin/live/controller.php… in any moment of the day i can see at a glance visitors and actions done since the midnight (like in google analytics), not in the last 24 hours… i have a bug tho, “midnight” means 1 am instead of 00 :)) If i remember correctly talked about this on the forums some 1 year ago and the “last 24 hours” counting was considered to be better… hence, i did it myself the way i like it :slight_smile:

  4. my site is consisting of only some 30-35 pages… so, i have created an unique representative png for each page and hard-coded the twig template “if action.url is that, then load this png”… it is way more useful for me than the standard incremental folder colors, because i can see visually which page has been viewed… again, I believe this only makes sense for sites with less than 50 pages or so, but on the other hand it only took me some 1 week to learn ALL the icons of each page, which i now recognize instantly… a small plugin to do this url-png pairs way more elegantly and easier for sure would be useful in the future…and least for part of piwik`s user-base.

That would be it… not that many, but each update requires me some 25 minutes to re-do all of that :slight_smile:

Anyway, the biggest of my modifications: the real-time web-desktop notifications… not being a php developer it was a nightmare to make it work the way i wanted, and is still having its limits although i poured more than 5 months of research into “refining” it :)… but it`s an extremely useful feature for me, because i can continue do whatever i am doing (like watching Helix ), but remain in touch with important events on my site (eg, someone is reaching checkout page, or contact, whatever)… i di hope that someday a more powerful version will make it to the core.