Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If dpr initially unknown, update in subsequent page impression #4

Open
wants to merge 2 commits into
base: 5.x-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion Columns/DevicePixelRatio.php
Expand Up @@ -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;
}
}
}
6 changes: 4 additions & 2 deletions 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.