diff --git a/vendor/magento/module-customer-segment/Model/Customer.php b/vendor/magento/module-customer-segment/Model/Customer.php
index 169859499b69..6e95be722f2a 100644
--- a/vendor/magento/module-customer-segment/Model/Customer.php
+++ b/vendor/magento/module-customer-segment/Model/Customer.php
@@ -460,7 +460,7 @@ public function addVisitorToWebsiteSegments($visitorSession, $websiteId, $segmen
         $visitorSession->setCustomerSegmentIds($visitorSegmentIds);
 
         $value = array_filter($visitorSegmentIds[$websiteId]);
-        $this->_httpContext->setValue(Data::CONTEXT_SEGMENT, $value, $value);
+        $this->_httpContext->setValue(Data::CONTEXT_SEGMENT, $value, []);
 
         return $this;
     }
@@ -493,7 +493,7 @@ public function removeVisitorFromWebsiteSegments($visitorSession, $websiteId, $s
             ? array_filter($visitorCustomerSegmentIds[$websiteId])
             : [];
 
-        $this->_httpContext->setValue(Data::CONTEXT_SEGMENT, $value, $value);
+        $this->_httpContext->setValue(Data::CONTEXT_SEGMENT, $value, []);
 
         return $this;
     }
@@ -505,6 +505,7 @@ public function removeVisitorFromWebsiteSegments($visitorSession, $websiteId, $s
      * @param int $websiteId
      * @param array $segmentIds
      * @return $this
+     * @throws LocalizedException
      */
     public function addCustomerToWebsiteSegments(int $customerId, int $websiteId, array $segmentIds): Customer
     {
@@ -522,6 +523,7 @@ public function addCustomerToWebsiteSegments(int $customerId, int $websiteId, ar
         $visitorCustomerSegmentIds[$websiteId] = !empty($visitorCustomerSegmentIds[$websiteId])
             ?  array_unique(array_merge($visitorCustomerSegmentIds[$websiteId], $value))
             :  $value;
+        sort($visitorCustomerSegmentIds[$websiteId]);
         $this->_customerSession->setCustomerSegmentIds($visitorCustomerSegmentIds);
 
         return $this;
diff --git a/vendor/magento/module-customer-segment/Model/Layout/DepersonalizePlugin.php b/vendor/magento/module-customer-segment/Model/Layout/DepersonalizePlugin.php
index 8efa0f07e80c..da5eda4cd7d5 100644
--- a/vendor/magento/module-customer-segment/Model/Layout/DepersonalizePlugin.php
+++ b/vendor/magento/module-customer-segment/Model/Layout/DepersonalizePlugin.php
@@ -115,13 +115,7 @@ public function afterGenerateElements(LayoutInterface $subject)
         ) {
             $websiteId = $this->storeManager->getWebsite()->getId();
             $value = $this->customerSegmentIds[$websiteId] ?? [];
-
-            if ($this->httpContext->getValue(Context::CONTEXT_AUTH)) {
-                $this->httpContext->setValue(Data::CONTEXT_SEGMENT, $value, []);
-            } else {
-                $this->httpContext->setValue(Data::CONTEXT_SEGMENT, $value, $value);
-            }
-
+            $this->httpContext->setValue(Data::CONTEXT_SEGMENT, $value, []);
             $this->customerSession->setCustomerSegmentIds($this->customerSegmentIds);
         }
     }
