# Screen pixel ratios

**URL:** <https://forum.pirsch.io/t/screen-pixel-ratios/36>\
**Category:** General\
**Created:** [January 21, 2024, 7:58am UTC](https://forum.pirsch.io/t/screen-pixel-ratios/36 "2024-01-21T07:58:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![KasperKamperman](https://forum.pirsch.io/user_avatar/forum.pirsch.io/kasperkamperman/32/29_2.png) [@KasperKamperman](https://forum.pirsch.io/u/KasperKamperman)\
**Post date:** [January 21, 2024, 7:58am UTC](https://forum.pirsch.io/t/screen-pixel-ratios/36/1 "2024-01-21T07:58:32Z")

</div>

Currently I can read the screen resolutions from the analytics. However, nowadays that alone doesn’t say that much. Different devices have also different pixel densities (1x, 2x, 3x). It would be interesting to see the device pixel ratio/dppx information too. It’s relevant when optimising images. However, I can’t find actual stats on that online.

For example if most visitor devices are 2x (which I assume), than it might not make sense to offer a 1x image at all.

[https://www.mydevice.io/](https://www.mydevice.io/)

Is this something that could be added, or is there a quick way to track it myself as with some custom event when a user visits a page?

---

<div class="post-metadata">

**Author:** ![Marvin](https://forum.pirsch.io/user_avatar/forum.pirsch.io/marvin/32/16_2.png) [@Marvin](https://forum.pirsch.io/u/Marvin)\
**Post date:** [January 21, 2024, 1:42pm UTC](https://forum.pirsch.io/t/screen-pixel-ratios/36/2 "2024-01-21T13:42:02Z")

</div>

Hi Kasper,

we currently use screen.width, which returns the screen resolution in CSS pixel:

> **[Screen: width property - Web APIs | MDN](https://developer.mozilla.org/en-US/docs/Web/API/Screen/width)**
>
> The Screen.width read-only property returns the width of
> the screen in CSS pixels.

I think this is reasonable, but we’ll think about adding support for dppx 🙂

---

<div class="post-metadata">

**Author:** ![KasperKamperman](https://forum.pirsch.io/user_avatar/forum.pirsch.io/kasperkamperman/32/29_2.png) [@KasperKamperman](https://forum.pirsch.io/u/KasperKamperman)\
**Post date:** [January 22, 2024, 8:47am UTC](https://forum.pirsch.io/t/screen-pixel-ratios/36/3 "2024-01-22T08:47:00Z")

</div>

Yes, I’m’ aware of the width property. Just figuring out if it makes sense to serve smaller images.

I tracked it now as an event. In the end it’s just to get an idea, not a metric I need to keep tracking.

```auto
 <script defer type="text/javascript">
  document.addEventListener("DOMContentLoaded", () => {

      const dprFlag = localStorage.getItem("pirsch_dpr");

      if(!dprFlag) {
          pirsch("Screen DPR", {
                  duration: window.devicePixelRatio,
                  meta: {
                      dpr: window.devicePixelRatio
                  }
              }).then(() => {
                  localStorage.setItem("pirsch_dpr", true);
              }).catch(e => {
                  console.error(e); 
              }
          );
      }
      else {
          console.log("dpr already sent");
          return;
      }
  });
     
</script>

```

Only the duration parameter is a bit vague to me. Is that used to calculate some average?

---

<div class="post-metadata">

**Author:** ![KasperKamperman](https://forum.pirsch.io/user_avatar/forum.pirsch.io/kasperkamperman/32/29_2.png) [@KasperKamperman](https://forum.pirsch.io/u/KasperKamperman)\
**Post date:** [January 22, 2024, 10:21am UTC](https://forum.pirsch.io/t/screen-pixel-ratios/36/4 "2024-01-22T10:21:13Z")

</div>

This is how it looks. Indeed duration seems to be averaged.

 ![Screenshot 2024-01-22 at 11.20.07](https://forum.pirsch.io/uploads/default/original/1X/f0ef0ff2a85d0b963a66b5ef32c97405fa323aa8.png)

---

<div class="post-metadata">

**Author:** ![Marvin](https://forum.pirsch.io/user_avatar/forum.pirsch.io/marvin/32/16_2.png) [@Marvin](https://forum.pirsch.io/u/Marvin)\
**Post date:** [January 22, 2024, 10:51am UTC](https://forum.pirsch.io/t/screen-pixel-ratios/36/5 "2024-01-22T10:51:53Z")

</div>

> [@KasperKamperman](#):
>
> Only the duration parameter is a bit vague to me. Is that used to calculate some average?

> [@KasperKamperman](#):
>
> This is how it looks. Indeed duration seems to be averaged.

Yes, duration is a bit special as it is used to calculate an average. Usually for time-related things (read time), but you can use it for whatever you like 🙂

Technically, we recently replaced it with custom metrics, that are a bit more flexible. However, I think your solution works well 👍

---

<div class="post-metadata">

**Author:** ![KasperKamperman](https://forum.pirsch.io/user_avatar/forum.pirsch.io/kasperkamperman/32/29_2.png) [@KasperKamperman](https://forum.pirsch.io/u/KasperKamperman)\
**Post date:** [January 22, 2024, 11:39am UTC](https://forum.pirsch.io/t/screen-pixel-ratios/36/6 "2024-01-22T11:39:07Z")

</div>

Do you have documentation on the custom metrics? I didn’t came across it when reading the documentation on events, but maybe I overlooked it.

---

<div class="post-metadata">

**Author:** ![Marvin](https://forum.pirsch.io/user_avatar/forum.pirsch.io/marvin/32/16_2.png) [@Marvin](https://forum.pirsch.io/u/Marvin)\
**Post date:** [January 22, 2024, 11:50am UTC](https://forum.pirsch.io/t/screen-pixel-ratios/36/7 "2024-01-22T11:50:58Z")

</div>

Sure! It requires a Plus subscription though. It’s part of the conversion goals article:

> **[Pirsch Analytics Documentation](https://docs.pirsch.io/advanced/conversion-goals#tracking-custom-metrics)**
>
> Pirsch is a simple, privacy-friendly, and open-source web analytics solution.
