This article documents a limitation when viewing content based on a User Segment in the Audience Targeting app that uses the Physical Screen Size attributes as a Mobile Device Rule. It was discovered that users could not view any content created with this set of conditions. This means that the Liferay instance cannot detect Desktop devices if the rule uses physical size attribute.
The Use Case
- Start Liferay DXP 7.0. (For testing purposes, we are using DXP 7.0.)
- Deploy the Audience Targeting and Mobile Device apps.
- Navigate to the Control Panel → Configuration → Mobile Device Families.
- Add a new Device Family called Desktop and a Classification Rule also called Desktop. Enter some values for Physical Screen Size classification rule.
- Navigate to Control Panel → Configuration → Audience Targeting.
- Create a User Segment:
- Name: Desktop Based
- Rules: Session Attributes → Device → Desktop.
- Create some content for this User Segment.
After the content has been created, in the tests, it was discovered that the segmented content for such conditions did not display when on a desktop device.
It was also discovered that even using a third party 'user-agent' browser add-on such as Chrome's User-Agent Switcher, the content was still not viewable.
The reason why user-agent switchers are not viable workarounds is because they typically do not contain information regarding the physical size of devices. Rather, they usually contain information related to the web browser or OS being used, or screen resolutions, not the physical dimensions of the monitor or laptop. (See below for the technical specifications.)
Resolution
Limitation - Workaround Available
The limitation is found in 51Degrees' implementation. (Note: 51Degrees is a third party detection tool used by Liferay DXP used to validate mobile device rules.)
Regardless of whether the user has a User-Agent app or not, 51Degrees' mobile detection device does not detect the physical dimensions due to the various hardware options. In other words, it cannot differentiate between a 17" monitor and a 19" monitor that have the same screen resolution. Instead, the mobile device rules track the screen resolution (for example 1920x1080, 1440x900) which are known values.
Two workarounds are available:
- 51Degrees offers a workaround by implementing a Client Side Override. This is a piece of Javascript that stores information about the device's physical size in a cookie. (This is considered development and beyond Liferay's Support Policy.)
- The other viable option is to use the Screen Resolution parameters which is out of the box. When creating the Classification Rules, specify the minimum and maximum width and height in pixels, such as 1920 x 1080.
The second option could be close enough to the actual sizes for most standard desktop monitors and the larger laptops.
Additional Information
For more general information about creating User Segments, here is the Managing User Segments article.
For reference: https://51degrees.com/resources/property-dictionary#ScreenMMWidth
ScreenMMWidth
Refers to the screen width of the device in millimetres. This property will return 'Unknown' for desktops or for devices which do not have an integrated screen.