From 98ad885f621536d51a31b2396866df0470496189 Mon Sep 17 00:00:00 2001 From: seb303 Date: Sun, 7 Apr 2024 15:19:25 +0100 Subject: [PATCH 1/2] If dpr initially unknown, update in subsequent page impression --- Columns/DevicePixelRatio.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Columns/DevicePixelRatio.php b/Columns/DevicePixelRatio.php index 578b60b..249a57f 100644 --- a/Columns/DevicePixelRatio.php +++ b/Columns/DevicePixelRatio.php @@ -94,6 +94,11 @@ public function onNewVisit(Request $request, Visitor $visitor, $action) */ public function onExistingVisit(Request $request, Visitor $visitor, $action) { - return false; + // In case the value was initially unknown, update it from a subsequent page impression + if (is_null($visitor->getVisitorColumn($this->columnName))) { + return $this->onNewVisit($request, $visitor, $action); + } else { + return false; + } } } From 71987ef3f2724cf3402bcb6d132ea85433869376 Mon Sep 17 00:00:00 2001 From: seb303 Date: Wed, 1 May 2024 21:00:24 +0100 Subject: [PATCH 2/2] If dpr initially unknown, will update in subsequent page impression --- docs/faq.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/faq.md b/docs/faq.md index 6026253..efabf7e 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -1,13 +1,15 @@ ## FAQ -__Shouldn't the plugin analyze the pure device pixel ratio, wihtout taking the zoom into account?__ +__Shouldn't the plugin analyze the pure device pixel ratio, without taking the zoom into account?__ -I do not think that you can query the browser for neither the full page zoom nor the pure pixel device ratio, window.pixelDeviceRatio gives you both at the same time. +I do not think that you can query the browser for either the full page zoom or the pure pixel device ratio, window.pixelDeviceRatio gives you both at the same time. __What if the device pixel ratio changes during the visit (e.g. by the user changing the full page zoom level)?__ The plugin records the device pixel ratio at the beginning of each visit, later changes are ignored. I might think about an option for taking the value for the last action instead, if you provide me with very good arguments for that. +The exception to this is if the device pixel ratio is initially unknown (for example if the first tracking event of a visit is generated server-side via the API). In this case the plugin will record the first known value from a subsquent tracking event in the visit. + __An unknown device pixel ratio is reported for all visitors. What is wrong?__ This plugin needs to add a snippet to the JavaScript code that make the browser report visitor actions. To allow this addition, matomo.js must be writable in you installation ("Writable JavaScript Tracker" in System Check must be checked). As the script might be cached on client side, it might take a while until all clients will correctly report the device pixel ratio. If you report the actions using some other API, add "devicePixelRatio=1.23" to the arguments.