The solution for Piwik (asuming you use the async tracker) is very similar:
This could, of course, need some testing and verification. You should probably test to see that 'devicePixelRatio' is available in the window object before using it.
var devicePixelRatio=(window.devicePixelRatio>1)?window.devicePixelRatio:'normal or unknown'; _paq.push(['setCustomVariable',1,'devicePixelRatio', devicePixelRatio, 'page']);
This could, of course, need some testing and verification. You should probably test to see that 'devicePixelRatio' is available in the window object before using it.
var devicePixelRatio=('devicePixelRatio' in window)?window.devicePixelRatio:'unknown'; _paq.push(['setCustomVariable',1,'devicePixelRatio',devicePixelRatio,'page']);