Drupal 8.x service for detecting device & browser information based on user agent.
Wrapper around DeviceDetector php package

Device Detector package:

The Universal Device Detection library will parse any User Agent and detect the browser, operating system, a device used (desktop, tablet, mobile, tv, cars, console, etc.), brand and model.
https://github.com/matomo-org/device-detector.

Usage:

This module does not do anything out of the box, just provide service which you can use in your code.
\Drupal::service('universal_device_detection.default')->detect();

If you want process bots as normal devices:
\Drupal::service('universal_device_detection.default')->detect(FALSE);

Example of response

array (
 'type' => 'desktop',
 'info' => 
 array (
 'client' => 
 array (
 'type' => 'browser',
 'name' => 'Chromium',
 'short_name' => 'CR',
 'version' => '73.0',
 'engine' => 'Blink',
 'engine_version' => '',
 ),
 'os' => 
 array (
 'name' => 'Ubuntu',
 'short_name' => 'UBT',
 'version' => '',
 'platform' => 'x64',
 ),
 'brand' => '',
 'model' => '',
 ),
)

Need help using or extending this module?

    Vallic
  • Hire the project maintainers: Vallic offers Drupal Commerce support and development, and runs Vallic Cloud, Drupal hosting.
  • Community support: Use the issue queue.
Supporting organizations:
Initial Development
Maintenance & Development

Project information

Releases

2.1.0 Stable release covered by the Drupal Security Team released 15 October 2024
Works with Drupal: ^9 || ^10 || ^11

Drupal 11.x compatibility

Install:

Development version: 2.x-dev updated 15 Oct 2024 at 11:03 UTC

2.0.0 Stable release covered by the Drupal Security Team released 20 November 2023
Works with Drupal: ^9 || ^10

D10 release

Install:

Development version: 2.0.x-dev updated 15 Oct 2024 at 10:57 UTC