diff --git a/plugins/DevicesDetection/VisitorDetails.php b/plugins/DevicesDetection/VisitorDetails.php
index d358c2d1eff38a867d63a8cdb0ee2dff23c65378..5b17fdc4e6c2a709e6e9669fcbfaeb27d85b7902 100644
--- a/plugins/DevicesDetection/VisitorDetails.php
+++ b/plugins/DevicesDetection/VisitorDetails.php
@@ -6,6 +6,7 @@
  * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
  *
  */
+
 namespace Piwik\Plugins\DevicesDetection;
 
 use Piwik\Plugins\Live\VisitorDetailsAbstract;
@@ -151,7 +152,7 @@ class VisitorDetails extends VisitorDetailsAbstract
     public function finalizeProfile($visits, &$profile)
     {
         $devices = $this->devices;
-        uksort($this->devices, function($a, $b) use ($devices) {
+        uksort($this->devices, function ($a, $b) use ($devices) {
             $cmp = strcmp($devices[$b]['count'], $devices[$a]['count']);
             if (0 == $cmp) {
                 $cmp = strcmp($a, $b);
@@ -159,6 +160,8 @@ class VisitorDetails extends VisitorDetailsAbstract
             return $cmp;
         });
 
+        $devices = [];
+
         foreach ($this->devices as $type => $devicesData) {
             $typeDevices = [];
             foreach ($devicesData['devices'] as $name => $count) {
@@ -167,9 +170,14 @@ class VisitorDetails extends VisitorDetailsAbstract
                     'count' => $count
                 ];
             }
-            $this->devices[$type]['devices'] = $typeDevices;
+            $devices[] = [
+                'type'    => $type,
+                'count'   => $devicesData['count'],
+                'icon'    => $devicesData['icon'],
+                'devices' => $typeDevices,
+            ];
         }
 
-        $profile['devices'] = $this->devices;
+        $profile['devices'] = $devices;
     }
 }
\ No newline at end of file
diff --git a/plugins/DevicesDetection/templates/_profileSummary.twig b/plugins/DevicesDetection/templates/_profileSummary.twig
index 05348864c5820babd56323b8d54d71a18548cf28..b1243026845df837dc298b3ff9b7776c04c514f5 100644
--- a/plugins/DevicesDetection/templates/_profileSummary.twig
+++ b/plugins/DevicesDetection/templates/_profileSummary.twig
@@ -2,13 +2,13 @@
     <div class="visitor-profile-summary visitor-profile-devices">
         <h1>{{ 'DevicesDetection_Devices'|translate }}</h1>
         <div>
-            {%- for type,entry in visitorData.devices -%}
+            {%- for entry in visitorData.devices -%}
                 <p>
                     <img height="16" src="{{ entry.icon }}" />
                     {% if entry.devices|length == 1 and 'General_Unknown'|translate in entry.devices[0].name %}
-                        <span>{{ 'DevicesDetection_XVisitsFromDevices'|translate('<strong>' ~ entry.count ~ '</strong>', '<strong>' ~ type ~ '</strong>')|raw }}
+                        <span>{{ 'DevicesDetection_XVisitsFromDevices'|translate('<strong>' ~ entry.count ~ '</strong>', '<strong>' ~ entry.type ~ '</strong>')|raw }}
                     {% else %}
-                    <span>{{ 'DevicesDetection_XVisitsFromDevices'|translate('<strong>' ~ entry.count ~ '</strong>', '<strong>' ~ type ~ '</strong>')|raw }}:
+                    <span>{{ 'DevicesDetection_XVisitsFromDevices'|translate('<strong>' ~ entry.count ~ '</strong>', '<strong>' ~ entry.type ~ '</strong>')|raw }}:
                         {% for device in entry.devices -%}
                             {{ device.name }} ({{ device.count }}x){% if not loop.last %}, {% endif %}
                         {%- endfor -%}
diff --git a/plugins/Live/tests/System/expected/test___Live.getVisitorProfile.xml b/plugins/Live/tests/System/expected/test___Live.getVisitorProfile.xml
index 878232f0c43cde9ced717ada3314211fd9907105..b65956d80a8b4371568535320592fe80836b7228 100644
--- a/plugins/Live/tests/System/expected/test___Live.getVisitorProfile.xml
+++ b/plugins/Live/tests/System/expected/test___Live.getVisitorProfile.xml
@@ -1210,7 +1210,8 @@
 		</row>
 	</visitedPages>
 	<devices>
-		<Unknown>
+		<row>
+			<type>Unknown</type>
 			<count>30</count>
 			<icon>plugins/Morpheus/icons/dist/devices/unknown.png</icon>
 			<devices>
@@ -1219,8 +1220,9 @@
 					<count>30</count>
 				</row>
 			</devices>
-		</Unknown>
-		<Desktop>
+		</row>
+		<row>
+			<type>Desktop</type>
 			<count>1</count>
 			<icon>plugins/Morpheus/icons/dist/devices/desktop.png</icon>
 			<devices>
@@ -1229,7 +1231,7 @@
 					<count>1</count>
 				</row>
 			</devices>
-		</Desktop>
+		</row>
 	</devices>
 	<continents>
 		<row>
diff --git a/plugins/Live/tests/System/expected/test_higherLimit__Live.getVisitorProfile.xml b/plugins/Live/tests/System/expected/test_higherLimit__Live.getVisitorProfile.xml
index 4071574fdc60508272caff97a466dc6ab6a1fe9d..09df3a8344c0ceae249b8a9639b0433b2d41d56b 100644
--- a/plugins/Live/tests/System/expected/test_higherLimit__Live.getVisitorProfile.xml
+++ b/plugins/Live/tests/System/expected/test_higherLimit__Live.getVisitorProfile.xml
@@ -2360,7 +2360,8 @@
 		</row>
 	</visitedPages>
 	<devices>
-		<Unknown>
+		<row>
+			<type>Unknown</type>
 			<count>30</count>
 			<icon>plugins/Morpheus/icons/dist/devices/unknown.png</icon>
 			<devices>
@@ -2369,8 +2370,9 @@
 					<count>30</count>
 				</row>
 			</devices>
-		</Unknown>
-		<Desktop>
+		</row>
+		<row>
+			<type>Desktop</type>
 			<count>1</count>
 			<icon>plugins/Morpheus/icons/dist/devices/desktop.png</icon>
 			<devices>
@@ -2379,7 +2381,7 @@
 					<count>1</count>
 				</row>
 			</devices>
-		</Desktop>
+		</row>
 	</devices>
 	<continents>
 		<row>
diff --git a/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__Live.getVisitorProfile.xml b/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__Live.getVisitorProfile.xml
index 7d19d39bcee2c638b2c00e7c657f38cbb3b50011..d12817f3797beb6870db92c8c60ff02b6877878a 100644
--- a/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__Live.getVisitorProfile.xml
+++ b/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__Live.getVisitorProfile.xml
@@ -309,7 +309,8 @@
 		</row>
 	</visitedPages>
 	<devices>
-		<Desktop>
+		<row>
+			<type>Desktop</type>
 			<count>2</count>
 			<icon>plugins/Morpheus/icons/dist/devices/desktop.png</icon>
 			<devices>
@@ -318,7 +319,7 @@
 					<count>2</count>
 				</row>
 			</devices>
-		</Desktop>
+		</row>
 	</devices>
 	<continents>
 		<row>
diff --git a/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI_pagesegment__Live.getVisitorProfile.xml b/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI_pagesegment__Live.getVisitorProfile.xml
index 7d19d39bcee2c638b2c00e7c657f38cbb3b50011..d12817f3797beb6870db92c8c60ff02b6877878a 100644
--- a/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI_pagesegment__Live.getVisitorProfile.xml
+++ b/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI_pagesegment__Live.getVisitorProfile.xml
@@ -309,7 +309,8 @@
 		</row>
 	</visitedPages>
 	<devices>
-		<Desktop>
+		<row>
+			<type>Desktop</type>
 			<count>2</count>
 			<icon>plugins/Morpheus/icons/dist/devices/desktop.png</icon>
 			<devices>
@@ -318,7 +319,7 @@
 					<count>2</count>
 				</row>
 			</devices>
-		</Desktop>
+		</row>
 	</devices>
 	<continents>
 		<row>