From 237f202c7a4ac7b659855d3078ae5a58c1ee3c65 Mon Sep 17 00:00:00 2001
From: diosmosis <benaka@piwik.pro>
Date: Mon, 14 Sep 2015 17:33:59 -0700
Subject: [PATCH] Refs #6031, #7213, add segment label to top level
 CustomVariables.getCustomVariables report for customVariableName.

---
 plugins/CustomVariables/API.php               |   2 ++
 ...CustomVariables.getCustomVariables_day.xml |  16 ++++++++++++++++
 ...stomVariables.getCustomVariables_month.xml |   8 ++++++++
 ...CustomVariables.getCustomVariables_day.xml |   7 +++++++
 ...stomVariables.getCustomVariables_month.xml |   5 +++++
 ...Site_lastN__API.getProcessedReport_day.xml |   4 ++++
 ...te_lastN__API.getProcessedReport_month.xml |   2 ++
 ...CustomVariables.getCustomVariables_day.csv | Bin 1280 -> 1984 bytes
 ...CustomVariables.getCustomVariables_day.xml |   7 +++++++
 ...stomVariables.getCustomVariables_range.xml |   7 +++++++
 ...stomVariables.getCustomVariables_range.xml |   7 +++++++
 ...CustomVariables.getCustomVariables_day.xml |   2 ++
 ...CustomVariables.getCustomVariables_day.xml |   2 ++
 ...CustomVariables.getCustomVariables_day.xml |  10 ++++++++++
 ...ustomVariables.getCustomVariables_week.xml |  10 ++++++++++
 ...CustomVariables.getCustomVariables_day.xml |   7 +++++++
 ...ustomVariables.getCustomVariables_week.xml |   7 +++++++
 ...CustomVariables.getCustomVariables_day.xml |   6 ++++++
 ...ustomVariables.getCustomVariables_week.xml |   6 ++++++
 19 files changed, 115 insertions(+)

diff --git a/plugins/CustomVariables/API.php b/plugins/CustomVariables/API.php
index 36d4e1ff9a..fa3a99dbca 100644
--- a/plugins/CustomVariables/API.php
+++ b/plugins/CustomVariables/API.php
@@ -73,6 +73,8 @@ class API extends \Piwik\Plugin\API
 
         if ($flat) {
             $dataTable->filterSubtables('Piwik\Plugins\CustomVariables\DataTable\Filter\CustomVariablesValuesFromNameId');
+        } else {
+            $dataTable->filter('AddSegmentByLabel', array('customVariableName'));
         }
 
         return $dataTable;
diff --git a/plugins/CustomVariables/tests/System/expected/test_CustomVariablesSystemTest__CustomVariables.getCustomVariables_day.xml b/plugins/CustomVariables/tests/System/expected/test_CustomVariablesSystemTest__CustomVariables.getCustomVariables_day.xml
index 1ecaf61b08..3a5683bdc6 100644
--- a/plugins/CustomVariables/tests/System/expected/test_CustomVariablesSystemTest__CustomVariables.getCustomVariables_day.xml
+++ b/plugins/CustomVariables/tests/System/expected/test_CustomVariablesSystemTest__CustomVariables.getCustomVariables_day.xml
@@ -3,6 +3,7 @@
 	<row>
 		<label>Name_PAGE_1</label>
 		<nb_actions>1</nb_actions>
+		<segment>customVariableName==Name_PAGE_1</segment>
 		<subtable>
 			<row>
 				<label>Val_PAGE1</label>
@@ -14,6 +15,7 @@
 	<row>
 		<label>Name_PAGE_2</label>
 		<nb_actions>1</nb_actions>
+		<segment>customVariableName==Name_PAGE_2</segment>
 		<subtable>
 			<row>
 				<label>Val_PAGE2</label>
@@ -25,6 +27,7 @@
 	<row>
 		<label>Name_PAGE_3</label>
 		<nb_actions>1</nb_actions>
+		<segment>customVariableName==Name_PAGE_3</segment>
 		<subtable>
 			<row>
 				<label>Val_PAGE3</label>
@@ -36,6 +39,7 @@
 	<row>
 		<label>Name_PAGE_4</label>
 		<nb_actions>1</nb_actions>
+		<segment>customVariableName==Name_PAGE_4</segment>
 		<subtable>
 			<row>
 				<label>Val_PAGE4</label>
@@ -47,6 +51,7 @@
 	<row>
 		<label>Name_PAGE_5</label>
 		<nb_actions>1</nb_actions>
+		<segment>customVariableName==Name_PAGE_5</segment>
 		<subtable>
 			<row>
 				<label>Val_PAGE5</label>
@@ -58,6 +63,7 @@
 	<row>
 		<label>Name_PAGE_6</label>
 		<nb_actions>1</nb_actions>
+		<segment>customVariableName==Name_PAGE_6</segment>
 		<subtable>
 			<row>
 				<label>Val_PAGE6</label>
@@ -69,6 +75,7 @@
 	<row>
 		<label>Name_PAGE_7</label>
 		<nb_actions>1</nb_actions>
+		<segment>customVariableName==Name_PAGE_7</segment>
 		<subtable>
 			<row>
 				<label>Val_PAGE7</label>
@@ -80,6 +87,7 @@
 	<row>
 		<label>Name_PAGE_8</label>
 		<nb_actions>1</nb_actions>
+		<segment>customVariableName==Name_PAGE_8</segment>
 		<subtable>
 			<row>
 				<label>Val_PAGE8</label>
@@ -105,6 +113,7 @@
 		</goals>
 		<nb_conversions>1</nb_conversions>
 		<revenue>0</revenue>
+		<segment>customVariableName==Name_VISIT_1</segment>
 		<subtable>
 			<row>
 				<label>Val_VISIT1</label>
@@ -143,6 +152,7 @@
 		</goals>
 		<nb_conversions>1</nb_conversions>
 		<revenue>0</revenue>
+		<segment>customVariableName==Name_VISIT_2</segment>
 		<subtable>
 			<row>
 				<label>Val_VISIT2</label>
@@ -181,6 +191,7 @@
 		</goals>
 		<nb_conversions>1</nb_conversions>
 		<revenue>0</revenue>
+		<segment>customVariableName==Name_VISIT_3</segment>
 		<subtable>
 			<row>
 				<label>Val_VISIT3</label>
@@ -219,6 +230,7 @@
 		</goals>
 		<nb_conversions>1</nb_conversions>
 		<revenue>0</revenue>
+		<segment>customVariableName==Name_VISIT_4</segment>
 		<subtable>
 			<row>
 				<label>Val_VISIT4</label>
@@ -257,6 +269,7 @@
 		</goals>
 		<nb_conversions>1</nb_conversions>
 		<revenue>0</revenue>
+		<segment>customVariableName==Name_VISIT_5</segment>
 		<subtable>
 			<row>
 				<label>Val_VISIT5</label>
@@ -295,6 +308,7 @@
 		</goals>
 		<nb_conversions>1</nb_conversions>
 		<revenue>0</revenue>
+		<segment>customVariableName==Name_VISIT_6</segment>
 		<subtable>
 			<row>
 				<label>Val_VISIT6</label>
@@ -333,6 +347,7 @@
 		</goals>
 		<nb_conversions>1</nb_conversions>
 		<revenue>0</revenue>
+		<segment>customVariableName==Name_VISIT_7</segment>
 		<subtable>
 			<row>
 				<label>Val_VISIT7</label>
@@ -371,6 +386,7 @@
 		</goals>
 		<nb_conversions>1</nb_conversions>
 		<revenue>0</revenue>
+		<segment>customVariableName==Name_VISIT_8</segment>
 		<subtable>
 			<row>
 				<label>Val_VISIT8</label>
diff --git a/tests/PHPUnit/System/expected/test_ImportLogs__CustomVariables.getCustomVariables_month.xml b/tests/PHPUnit/System/expected/test_ImportLogs__CustomVariables.getCustomVariables_month.xml
index d24c6ab527..dc1a11ab2b 100644
--- a/tests/PHPUnit/System/expected/test_ImportLogs__CustomVariables.getCustomVariables_month.xml
+++ b/tests/PHPUnit/System/expected/test_ImportLogs__CustomVariables.getCustomVariables_month.xml
@@ -3,6 +3,7 @@
 	<row>
 		<label>HTTP-code</label>
 		<nb_actions>43</nb_actions>
+		<segment>customVariableName==HTTP-code</segment>
 		<subtable>
 			<row>
 				<label>200</label>
@@ -60,6 +61,7 @@
 		<revenue>25</revenue>
 		<sum_daily_nb_uniq_visitors>7</sum_daily_nb_uniq_visitors>
 		<sum_daily_nb_users>0</sum_daily_nb_users>
+		<segment>customVariableName==Not-Bot</segment>
 		<subtable>
 			<row>
 				<label>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.24 (KHTML, like Gecko) RockMelt/0.9.58.494 Chrome/11.0.696.71 Safari/534.24</label>
@@ -149,6 +151,7 @@
 		<revenue>10</revenue>
 		<sum_daily_nb_uniq_visitors>3</sum_daily_nb_uniq_visitors>
 		<sum_daily_nb_users>1</sum_daily_nb_users>
+		<segment>customVariableName==User+Name</segment>
 		<subtable>
 			<row>
 				<label>user1</label>
@@ -193,6 +196,7 @@
 	<row>
 		<label>Generation Time</label>
 		<nb_actions>4</nb_actions>
+		<segment>customVariableName==Generation+Time</segment>
 		<subtable>
 			<row>
 				<label>359</label>
@@ -217,6 +221,7 @@
 	<row>
 		<label>Windows Status Code</label>
 		<nb_actions>4</nb_actions>
+		<segment>customVariableName==Windows+Status+Code</segment>
 		<subtable>
 			<row>
 				<label>24</label>
@@ -262,6 +267,7 @@
 		<revenue>5</revenue>
 		<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 		<sum_daily_nb_users>0</sum_daily_nb_users>
+		<segment>customVariableName==Bot</segment>
 		<subtable>
 			<row>
 				<label>Googlebot/2.1 ( http://www.googlebot.com/bot.html)</label>
@@ -302,6 +308,7 @@
 		<revenue>5</revenue>
 		<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 		<sum_daily_nb_users>0</sum_daily_nb_users>
+		<segment>customVariableName==Forum+status</segment>
 		<subtable>
 			<row>
 				<label>Anonymous</label>
@@ -342,6 +349,7 @@
 		<revenue>5</revenue>
 		<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 		<sum_daily_nb_users>0</sum_daily_nb_users>
+		<segment>customVariableName==VisitorType</segment>
 		<subtable>
 			<row>
 				<label>NewLoggedOut</label>
diff --git a/tests/PHPUnit/System/expected/test_SiteSearch_AllSites__CustomVariables.getCustomVariables_day.xml b/tests/PHPUnit/System/expected/test_SiteSearch_AllSites__CustomVariables.getCustomVariables_day.xml
index 55f9028117..9a056e8786 100644
--- a/tests/PHPUnit/System/expected/test_SiteSearch_AllSites__CustomVariables.getCustomVariables_day.xml
+++ b/tests/PHPUnit/System/expected/test_SiteSearch_AllSites__CustomVariables.getCustomVariables_day.xml
@@ -6,6 +6,7 @@
 				<label>_pk_scount</label>
 				<nb_visits>4</nb_visits>
 				<nb_actions>6</nb_actions>
+				<segment>customVariableName==_pk_scount</segment>
 				<subtable>
 					<row>
 						<label>0</label>
@@ -23,6 +24,7 @@
 				<label>_pk_scat</label>
 				<nb_visits>2</nb_visits>
 				<nb_actions>3</nb_actions>
+				<segment>customVariableName==_pk_scat</segment>
 				<subtable>
 					<row>
 						<label>Search Category</label>
@@ -37,6 +39,7 @@
 				<label>_pk_scount</label>
 				<nb_visits>3</nb_visits>
 				<nb_actions>3</nb_actions>
+				<segment>customVariableName==_pk_scount</segment>
 				<subtable>
 					<row>
 						<label>0</label>
@@ -59,6 +62,7 @@
 				<label>_pk_scat</label>
 				<nb_visits>2</nb_visits>
 				<nb_actions>2</nb_actions>
+				<segment>customVariableName==_pk_scat</segment>
 				<subtable>
 					<row>
 						<label>Bad No Result Category :(</label>
@@ -85,6 +89,7 @@
 				<label>_pk_scount</label>
 				<nb_visits>1</nb_visits>
 				<nb_actions>2</nb_actions>
+				<segment>customVariableName==_pk_scount</segment>
 				<subtable>
 					<row>
 						<label>0</label>
@@ -97,6 +102,7 @@
 				<label>_pk_scat</label>
 				<nb_visits>1</nb_visits>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==_pk_scat</segment>
 				<subtable>
 					<row>
 						<label>Bad No Result Category bis :(</label>
@@ -124,6 +130,7 @@
 				<sum_visit_length>541</sum_visit_length>
 				<bounce_count>0</bounce_count>
 				<nb_visits_converted>0</nb_visits_converted>
+				<segment>customVariableName==test+cvar+name</segment>
 				<subtable>
 					<row>
 						<label>test cvar value</label>
diff --git a/tests/PHPUnit/System/expected/test_SiteSearch_AllSites__CustomVariables.getCustomVariables_month.xml b/tests/PHPUnit/System/expected/test_SiteSearch_AllSites__CustomVariables.getCustomVariables_month.xml
index 1a0871477a..50b6b4821e 100644
--- a/tests/PHPUnit/System/expected/test_SiteSearch_AllSites__CustomVariables.getCustomVariables_month.xml
+++ b/tests/PHPUnit/System/expected/test_SiteSearch_AllSites__CustomVariables.getCustomVariables_month.xml
@@ -7,6 +7,7 @@
 				<nb_visits>7</nb_visits>
 				<nb_actions>9</nb_actions>
 				<sum_daily_nb_uniq_visitors>7</sum_daily_nb_uniq_visitors>
+				<segment>customVariableName==_pk_scount</segment>
 				<subtable>
 					<row>
 						<label>0</label>
@@ -33,6 +34,7 @@
 				<nb_visits>4</nb_visits>
 				<nb_actions>5</nb_actions>
 				<sum_daily_nb_uniq_visitors>4</sum_daily_nb_uniq_visitors>
+				<segment>customVariableName==_pk_scat</segment>
 				<subtable>
 					<row>
 						<label>Search Category</label>
@@ -69,6 +71,7 @@
 				<nb_visits>1</nb_visits>
 				<nb_actions>2</nb_actions>
 				<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
+				<segment>customVariableName==_pk_scount</segment>
 				<subtable>
 					<row>
 						<label>0</label>
@@ -83,6 +86,7 @@
 				<nb_visits>1</nb_visits>
 				<nb_actions>1</nb_actions>
 				<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
+				<segment>customVariableName==_pk_scat</segment>
 				<subtable>
 					<row>
 						<label>Bad No Result Category bis :(</label>
@@ -112,6 +116,7 @@
 				<nb_visits_converted>0</nb_visits_converted>
 				<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 				<sum_daily_nb_users>0</sum_daily_nb_users>
+				<segment>customVariableName==test+cvar+name</segment>
 				<subtable>
 					<row>
 						<label>test cvar value</label>
diff --git a/tests/PHPUnit/System/expected/test_SiteSearch_CustomVariables.getCustomVariables_firstSite_lastN__API.getProcessedReport_day.xml b/tests/PHPUnit/System/expected/test_SiteSearch_CustomVariables.getCustomVariables_firstSite_lastN__API.getProcessedReport_day.xml
index 6b9e9e90a5..2cf589667d 100644
--- a/tests/PHPUnit/System/expected/test_SiteSearch_CustomVariables.getCustomVariables_firstSite_lastN__API.getProcessedReport_day.xml
+++ b/tests/PHPUnit/System/expected/test_SiteSearch_CustomVariables.getCustomVariables_firstSite_lastN__API.getProcessedReport_day.xml
@@ -112,20 +112,24 @@
 		<result prettyDate="Sunday 3 January 2010">
 			<row>
 				
+				<segment>customVariableName==_pk_scount</segment>
 				<idsubdatatable>3205</idsubdatatable>
 			</row>
 			<row>
 				
+				<segment>customVariableName==_pk_scat</segment>
 				<idsubdatatable>3204</idsubdatatable>
 			</row>
 		</result>
 		<result prettyDate="Monday 4 January 2010">
 			<row>
 				
+				<segment>customVariableName==_pk_scount</segment>
 				<idsubdatatable>3208</idsubdatatable>
 			</row>
 			<row>
 				
+				<segment>customVariableName==_pk_scat</segment>
 				<idsubdatatable>3207</idsubdatatable>
 			</row>
 		</result>
diff --git a/tests/PHPUnit/System/expected/test_SiteSearch_CustomVariables.getCustomVariables_firstSite_lastN__API.getProcessedReport_month.xml b/tests/PHPUnit/System/expected/test_SiteSearch_CustomVariables.getCustomVariables_firstSite_lastN__API.getProcessedReport_month.xml
index c30fb00bc6..f659e26078 100644
--- a/tests/PHPUnit/System/expected/test_SiteSearch_CustomVariables.getCustomVariables_firstSite_lastN__API.getProcessedReport_month.xml
+++ b/tests/PHPUnit/System/expected/test_SiteSearch_CustomVariables.getCustomVariables_firstSite_lastN__API.getProcessedReport_month.xml
@@ -81,10 +81,12 @@
 		<result prettyDate="2010, January">
 			<row>
 				
+				<segment>customVariableName==_pk_scount</segment>
 				<idsubdatatable>3230</idsubdatatable>
 			</row>
 			<row>
 				
+				<segment>customVariableName==_pk_scat</segment>
 				<idsubdatatable>3229</idsubdatatable>
 			</row>
 		</result>
diff --git a/tests/PHPUnit/System/expected/test_csvExport_xp0__CustomVariables.getCustomVariables_day.csv b/tests/PHPUnit/System/expected/test_csvExport_xp0__CustomVariables.getCustomVariables_day.csv
index 89e329416e9157f6b133d816fdcbcdcd1aa6dee4..d8449e77cdf17f888efb9f30d498ae680652eefa 100644
GIT binary patch
literal 1984
zcmcJPO>@&Q5Qg7#eueMKfu?+%dgw42V1|zllrWq!P8^&-J|M9v?T@ECD^<1|($q}K
zcw|d!Y4_2qU0wg4E7eF7&DGVC-cUa^(}q^?j<!@|#xt#$Q(H^=6Ro{vfuCQj-k!Np
zsl_d?Lt;(vljCtpgb`j##$&8Q-eFYmC#Rn>dxL$ZtQw!_2uq-~`Ae7sM@`sfZF8p~
za`aT-FT0mu%`A(&gnzPkcJBb*dhH>+=4G3Azk=Jd7woa%JTjVnhyL_)PS+GD)X|{I
zoE5Rob*b-Omt(YfLVHBB{xkLbxJN&>BmUac<!nQXv+F-&blwnYMa%&NYvNh<T0Xs{
zXCx;)yE!`gpgvTIKIs+Tm-PC2qci%S=?`?O*ZPPp#5dB&aIB|#d^2wHb+Og7ZTSL+
zt2kVP!!<aJ*px2(z7zkpJhzxech}RNqxSA9?{<z>b(YhKF3@<+llWW0RO;)!*K6)8
zFXvCn`Dc6!*g_>6bEqIw>;EZPle&u3c~a9ckUHq?j>zS1NZk(7j^1INLcQh=s`D(N
z!kcPL(PPZKgiM^`x5T^c-R{s`3Ya=0R%HDD0)wsps&A}Xz_g-5eh|^Jx+KyCcj%?A
z&@9$PtO(0M)6(oQ1MA8NnGo!;j+(pJS1r5u?Hc<wZR5V(t$jzW|2}!s`rr56p#m+N
ua@0t9+pQY*duXn2`)z+4B-{|EdO<cN)Z=sV<c$79akae*Tt(p;6n_96DN?@x

delta 39
tcmX@W-@vs&i)peCQ^MpoKs=AxY_bST(_}8z3zH|X834t!CabWU000xl4OajF

diff --git a/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems__CustomVariables.getCustomVariables_day.xml b/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems__CustomVariables.getCustomVariables_day.xml
index 8dd490bdb3..1d0ee64c8d 100755
--- a/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems__CustomVariables.getCustomVariables_day.xml
+++ b/tests/PHPUnit/System/expected/test_ecommerceOrderWithItems__CustomVariables.getCustomVariables_day.xml
@@ -33,6 +33,7 @@
 		</goals>
 		<nb_conversions>3</nb_conversions>
 		<revenue>3121.11</revenue>
+		<segment>customVariableName==ValueIsZero</segment>
 		<subtable>
 			<row>
 				<label>0</label>
@@ -103,6 +104,7 @@
 		</goals>
 		<nb_conversions>3</nb_conversions>
 		<revenue>3121.11</revenue>
+		<segment>customVariableName==VisitorType</segment>
 		<subtable>
 			<row>
 				<label>NewLoggedOut</label>
@@ -144,6 +146,7 @@
 		<label>_pkc</label>
 		<nb_visits>7</nb_visits>
 		<nb_actions>12</nb_actions>
+		<segment>customVariableName==_pkc</segment>
 		<subtable>
 			<row>
 				<label>Electronics &amp; Cameras</label>
@@ -188,6 +191,7 @@
 		<label>_pkn</label>
 		<nb_visits>6</nb_visits>
 		<nb_actions>11</nb_actions>
+		<segment>customVariableName==_pkn</segment>
 		<subtable>
 			<row>
 				<label>PRODUCT name</label>
@@ -212,6 +216,7 @@
 		<label>_pks</label>
 		<nb_visits>6</nb_visits>
 		<nb_actions>11</nb_actions>
+		<segment>customVariableName==_pks</segment>
 		<subtable>
 			<row>
 				<label>SKU VERY nice indeed</label>
@@ -260,6 +265,7 @@
 		</goals>
 		<nb_conversions>2</nb_conversions>
 		<revenue>3111.11</revenue>
+		<segment>customVariableName==VisitorName</segment>
 		<subtable>
 			<row>
 				<label>Great name!</label>
@@ -296,6 +302,7 @@
 		<label>_pkp</label>
 		<nb_visits>8</nb_visits>
 		<nb_actions>8</nb_actions>
+		<segment>customVariableName==_pkp</segment>
 		<subtable>
 			<row>
 				<label>333</label>
diff --git a/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__CustomVariables.getCustomVariables_range.xml b/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__CustomVariables.getCustomVariables_range.xml
index 1639c238a3..00acc7d7d0 100644
--- a/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__CustomVariables.getCustomVariables_range.xml
+++ b/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI__CustomVariables.getCustomVariables_range.xml
@@ -23,6 +23,7 @@
 		<revenue>1000</revenue>
 		<sum_daily_nb_uniq_visitors>2</sum_daily_nb_uniq_visitors>
 		<sum_daily_nb_users>0</sum_daily_nb_users>
+		<segment>customVariableName==VisitorType</segment>
 		<subtable>
 			<row>
 				<label>LoggedIn</label>
@@ -87,6 +88,7 @@
 		<revenue>0</revenue>
 		<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 		<sum_daily_nb_users>0</sum_daily_nb_users>
+		<segment>customVariableName==SET+WITH+EMPTY+VALUE</segment>
 		<subtable>
 			<row>
 				<label>Value not defined</label>
@@ -112,6 +114,7 @@
 	<row>
 		<label>Status user</label>
 		<nb_actions>3</nb_actions>
+		<segment>customVariableName==Status+user</segment>
 		<subtable>
 			<row>
 				<label>looking at &quot;profile page&quot;</label>
@@ -145,6 +148,7 @@
 		<revenue>0</revenue>
 		<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 		<sum_daily_nb_users>0</sum_daily_nb_users>
+		<segment>customVariableName==Value+will+be+VERY+long+and+truncated</segment>
 		<subtable>
 			<row>
 				<label>abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrst</label>
@@ -185,6 +189,7 @@
 		<revenue>1000</revenue>
 		<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 		<sum_daily_nb_users>0</sum_daily_nb_users>
+		<segment>customVariableName==Othercustom+value+which+should+be+truncated+abcdefghijklmnopqrstuvwxyz</segment>
 		<subtable>
 			<row>
 				<label>abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz</label>
@@ -210,6 +215,7 @@
 	<row>
 		<label>Language</label>
 		<nb_actions>1</nb_actions>
+		<segment>customVariableName==Language</segment>
 		<subtable>
 			<row>
 				<label>FR</label>
@@ -222,6 +228,7 @@
 	<row>
 		<label>SET WITH EMPTY VALUE PAGE SCOPE</label>
 		<nb_actions>1</nb_actions>
+		<segment>customVariableName==SET+WITH+EMPTY+VALUE+PAGE+SCOPE</segment>
 		<subtable>
 			<row>
 				<label>Value not defined</label>
diff --git a/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI_pagesegment__CustomVariables.getCustomVariables_range.xml b/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI_pagesegment__CustomVariables.getCustomVariables_range.xml
index 1639c238a3..00acc7d7d0 100644
--- a/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI_pagesegment__CustomVariables.getCustomVariables_range.xml
+++ b/tests/PHPUnit/System/expected/test_periodIsRange_dateIsLastN_MetadataAndNormalAPI_pagesegment__CustomVariables.getCustomVariables_range.xml
@@ -23,6 +23,7 @@
 		<revenue>1000</revenue>
 		<sum_daily_nb_uniq_visitors>2</sum_daily_nb_uniq_visitors>
 		<sum_daily_nb_users>0</sum_daily_nb_users>
+		<segment>customVariableName==VisitorType</segment>
 		<subtable>
 			<row>
 				<label>LoggedIn</label>
@@ -87,6 +88,7 @@
 		<revenue>0</revenue>
 		<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 		<sum_daily_nb_users>0</sum_daily_nb_users>
+		<segment>customVariableName==SET+WITH+EMPTY+VALUE</segment>
 		<subtable>
 			<row>
 				<label>Value not defined</label>
@@ -112,6 +114,7 @@
 	<row>
 		<label>Status user</label>
 		<nb_actions>3</nb_actions>
+		<segment>customVariableName==Status+user</segment>
 		<subtable>
 			<row>
 				<label>looking at &quot;profile page&quot;</label>
@@ -145,6 +148,7 @@
 		<revenue>0</revenue>
 		<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 		<sum_daily_nb_users>0</sum_daily_nb_users>
+		<segment>customVariableName==Value+will+be+VERY+long+and+truncated</segment>
 		<subtable>
 			<row>
 				<label>abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrst</label>
@@ -185,6 +189,7 @@
 		<revenue>1000</revenue>
 		<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 		<sum_daily_nb_users>0</sum_daily_nb_users>
+		<segment>customVariableName==Othercustom+value+which+should+be+truncated+abcdefghijklmnopqrstuvwxyz</segment>
 		<subtable>
 			<row>
 				<label>abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz</label>
@@ -210,6 +215,7 @@
 	<row>
 		<label>Language</label>
 		<nb_actions>1</nb_actions>
+		<segment>customVariableName==Language</segment>
 		<subtable>
 			<row>
 				<label>FR</label>
@@ -222,6 +228,7 @@
 	<row>
 		<label>SET WITH EMPTY VALUE PAGE SCOPE</label>
 		<nb_actions>1</nb_actions>
+		<segment>customVariableName==SET+WITH+EMPTY+VALUE+PAGE+SCOPE</segment>
 		<subtable>
 			<row>
 				<label>Value not defined</label>
diff --git a/tests/PHPUnit/System/expected/test_reportLimiting__CustomVariables.getCustomVariables_day.xml b/tests/PHPUnit/System/expected/test_reportLimiting__CustomVariables.getCustomVariables_day.xml
index 994f62a320..6b7a4a8b1c 100644
--- a/tests/PHPUnit/System/expected/test_reportLimiting__CustomVariables.getCustomVariables_day.xml
+++ b/tests/PHPUnit/System/expected/test_reportLimiting__CustomVariables.getCustomVariables_day.xml
@@ -3,6 +3,7 @@
 	<row>
 		<label>liked</label>
 		<nb_actions>20</nb_actions>
+		<segment>customVariableName==liked</segment>
 		<subtable>
 			<row>
 				<label>y</label>
@@ -19,6 +20,7 @@
 	<row>
 		<label>tweeted</label>
 		<nb_actions>20</nb_actions>
+		<segment>customVariableName==tweeted</segment>
 		<subtable>
 			<row>
 				<label>n</label>
diff --git a/tests/PHPUnit/System/expected/test_reportLimiting_rankingQuery__CustomVariables.getCustomVariables_day.xml b/tests/PHPUnit/System/expected/test_reportLimiting_rankingQuery__CustomVariables.getCustomVariables_day.xml
index 994f62a320..6b7a4a8b1c 100644
--- a/tests/PHPUnit/System/expected/test_reportLimiting_rankingQuery__CustomVariables.getCustomVariables_day.xml
+++ b/tests/PHPUnit/System/expected/test_reportLimiting_rankingQuery__CustomVariables.getCustomVariables_day.xml
@@ -3,6 +3,7 @@
 	<row>
 		<label>liked</label>
 		<nb_actions>20</nb_actions>
+		<segment>customVariableName==liked</segment>
 		<subtable>
 			<row>
 				<label>y</label>
@@ -19,6 +20,7 @@
 	<row>
 		<label>tweeted</label>
 		<nb_actions>20</nb_actions>
+		<segment>customVariableName==tweeted</segment>
 		<subtable>
 			<row>
 				<label>n</label>
diff --git a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables__CustomVariables.getCustomVariables_day.xml b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables__CustomVariables.getCustomVariables_day.xml
index c92fc50036..ebbd07023b 100644
--- a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables__CustomVariables.getCustomVariables_day.xml
+++ b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables__CustomVariables.getCustomVariables_day.xml
@@ -24,6 +24,7 @@
 				</goals>
 				<nb_conversions>3</nb_conversions>
 				<revenue>1000</revenue>
+				<segment>customVariableName==VisitorType</segment>
 				<subtable>
 					<row>
 						<label>LoggedIn</label>
@@ -85,6 +86,7 @@
 				</goals>
 				<nb_conversions>1</nb_conversions>
 				<revenue>0</revenue>
+				<segment>customVariableName==SET+WITH+EMPTY+VALUE</segment>
 				<subtable>
 					<row>
 						<label>Value not defined</label>
@@ -123,6 +125,7 @@
 				</goals>
 				<nb_conversions>1</nb_conversions>
 				<revenue>0</revenue>
+				<segment>customVariableName==Value+will+be+VERY+long+and+truncated</segment>
 				<subtable>
 					<row>
 						<label>abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrst</label>
@@ -147,6 +150,7 @@
 			<row>
 				<label>Status user</label>
 				<nb_actions>3</nb_actions>
+				<segment>customVariableName==Status+user</segment>
 				<subtable>
 					<row>
 						<label>looking at &quot;profile page&quot;</label>
@@ -177,6 +181,7 @@
 				</goals>
 				<nb_conversions>1</nb_conversions>
 				<revenue>1000</revenue>
+				<segment>customVariableName==Othercustom+value+which+should+be+truncated+abcdefghijklmnopqrstuvwxyz</segment>
 				<subtable>
 					<row>
 						<label>abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz</label>
@@ -201,6 +206,7 @@
 			<row>
 				<label>Language</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==Language</segment>
 				<subtable>
 					<row>
 						<label>FR</label>
@@ -212,6 +218,7 @@
 			<row>
 				<label>SET WITH EMPTY VALUE PAGE SCOPE</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==SET+WITH+EMPTY+VALUE+PAGE+SCOPE</segment>
 				<subtable>
 					<row>
 						<label>Value not defined</label>
@@ -223,6 +230,7 @@
 			<row>
 				<label>var1</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==var1</segment>
 				<subtable>
 					<row>
 						<label>looking at &quot;profile page&quot;</label>
@@ -234,6 +242,7 @@
 			<row>
 				<label>var2</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==var2</segment>
 				<subtable>
 					<row>
 						<label>&amp;#039;looking at &quot;\profile page&quot;&amp;#039;</label>
@@ -245,6 +254,7 @@
 			<row>
 				<label>var3</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==var3</segment>
 				<subtable>
 					<row>
 						<label>\looking at &quot;\profile page&quot;\</label>
diff --git a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables__CustomVariables.getCustomVariables_week.xml b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables__CustomVariables.getCustomVariables_week.xml
index 60639711b9..92a4a5c7be 100644
--- a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables__CustomVariables.getCustomVariables_week.xml
+++ b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables__CustomVariables.getCustomVariables_week.xml
@@ -25,6 +25,7 @@
 				<revenue>1000</revenue>
 				<sum_daily_nb_uniq_visitors>2</sum_daily_nb_uniq_visitors>
 				<sum_daily_nb_users>0</sum_daily_nb_users>
+				<segment>customVariableName==VisitorType</segment>
 				<subtable>
 					<row>
 						<label>LoggedIn</label>
@@ -89,6 +90,7 @@
 				<revenue>0</revenue>
 				<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 				<sum_daily_nb_users>0</sum_daily_nb_users>
+				<segment>customVariableName==SET+WITH+EMPTY+VALUE</segment>
 				<subtable>
 					<row>
 						<label>Value not defined</label>
@@ -129,6 +131,7 @@
 				<revenue>0</revenue>
 				<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 				<sum_daily_nb_users>0</sum_daily_nb_users>
+				<segment>customVariableName==Value+will+be+VERY+long+and+truncated</segment>
 				<subtable>
 					<row>
 						<label>abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrst</label>
@@ -154,6 +157,7 @@
 			<row>
 				<label>Status user</label>
 				<nb_actions>3</nb_actions>
+				<segment>customVariableName==Status+user</segment>
 				<subtable>
 					<row>
 						<label>looking at &quot;profile page&quot;</label>
@@ -187,6 +191,7 @@
 				<revenue>1000</revenue>
 				<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 				<sum_daily_nb_users>0</sum_daily_nb_users>
+				<segment>customVariableName==Othercustom+value+which+should+be+truncated+abcdefghijklmnopqrstuvwxyz</segment>
 				<subtable>
 					<row>
 						<label>abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz</label>
@@ -212,6 +217,7 @@
 			<row>
 				<label>Language</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==Language</segment>
 				<subtable>
 					<row>
 						<label>FR</label>
@@ -224,6 +230,7 @@
 			<row>
 				<label>SET WITH EMPTY VALUE PAGE SCOPE</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==SET+WITH+EMPTY+VALUE+PAGE+SCOPE</segment>
 				<subtable>
 					<row>
 						<label>Value not defined</label>
@@ -236,6 +243,7 @@
 			<row>
 				<label>var1</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==var1</segment>
 				<subtable>
 					<row>
 						<label>looking at &quot;profile page&quot;</label>
@@ -248,6 +256,7 @@
 			<row>
 				<label>var2</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==var2</segment>
 				<subtable>
 					<row>
 						<label>&amp;#039;looking at &quot;\profile page&quot;&amp;#039;</label>
@@ -260,6 +269,7 @@
 			<row>
 				<label>var3</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==var3</segment>
 				<subtable>
 					<row>
 						<label>\looking at &quot;\profile page&quot;\</label>
diff --git a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchALL_noGoalData__CustomVariables.getCustomVariables_day.xml b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchALL_noGoalData__CustomVariables.getCustomVariables_day.xml
index 5b779b60c6..7e941dea10 100644
--- a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchALL_noGoalData__CustomVariables.getCustomVariables_day.xml
+++ b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchALL_noGoalData__CustomVariables.getCustomVariables_day.xml
@@ -24,6 +24,7 @@
 				</goals>
 				<nb_conversions>3</nb_conversions>
 				<revenue>1000</revenue>
+				<segment>customVariableName==VisitorType</segment>
 				<subtable>
 					<row>
 						<label>LoggedIn</label>
@@ -85,6 +86,7 @@
 				</goals>
 				<nb_conversions>1</nb_conversions>
 				<revenue>0</revenue>
+				<segment>customVariableName==SET+WITH+EMPTY+VALUE</segment>
 				<subtable>
 					<row>
 						<label>Value not defined</label>
@@ -109,6 +111,7 @@
 			<row>
 				<label>Status user</label>
 				<nb_actions>3</nb_actions>
+				<segment>customVariableName==Status+user</segment>
 				<subtable>
 					<row>
 						<label>looking at &quot;profile page&quot;</label>
@@ -139,6 +142,7 @@
 				</goals>
 				<nb_conversions>1</nb_conversions>
 				<revenue>0</revenue>
+				<segment>customVariableName==Value+will+be+VERY+long+and+truncated</segment>
 				<subtable>
 					<row>
 						<label>abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrst</label>
@@ -177,6 +181,7 @@
 				</goals>
 				<nb_conversions>1</nb_conversions>
 				<revenue>1000</revenue>
+				<segment>customVariableName==Othercustom+value+which+should+be+truncated+abcdefghijklmnopqrstuvwxyz</segment>
 				<subtable>
 					<row>
 						<label>abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz</label>
@@ -201,6 +206,7 @@
 			<row>
 				<label>Language</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==Language</segment>
 				<subtable>
 					<row>
 						<label>FR</label>
@@ -212,6 +218,7 @@
 			<row>
 				<label>SET WITH EMPTY VALUE PAGE SCOPE</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==SET+WITH+EMPTY+VALUE+PAGE+SCOPE</segment>
 				<subtable>
 					<row>
 						<label>Value not defined</label>
diff --git a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchALL_noGoalData__CustomVariables.getCustomVariables_week.xml b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchALL_noGoalData__CustomVariables.getCustomVariables_week.xml
index 6b156a1379..54f91c076f 100644
--- a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchALL_noGoalData__CustomVariables.getCustomVariables_week.xml
+++ b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchALL_noGoalData__CustomVariables.getCustomVariables_week.xml
@@ -25,6 +25,7 @@
 				<revenue>1000</revenue>
 				<sum_daily_nb_uniq_visitors>2</sum_daily_nb_uniq_visitors>
 				<sum_daily_nb_users>0</sum_daily_nb_users>
+				<segment>customVariableName==VisitorType</segment>
 				<subtable>
 					<row>
 						<label>LoggedIn</label>
@@ -89,6 +90,7 @@
 				<revenue>0</revenue>
 				<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 				<sum_daily_nb_users>0</sum_daily_nb_users>
+				<segment>customVariableName==SET+WITH+EMPTY+VALUE</segment>
 				<subtable>
 					<row>
 						<label>Value not defined</label>
@@ -114,6 +116,7 @@
 			<row>
 				<label>Status user</label>
 				<nb_actions>3</nb_actions>
+				<segment>customVariableName==Status+user</segment>
 				<subtable>
 					<row>
 						<label>looking at &quot;profile page&quot;</label>
@@ -147,6 +150,7 @@
 				<revenue>0</revenue>
 				<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 				<sum_daily_nb_users>0</sum_daily_nb_users>
+				<segment>customVariableName==Value+will+be+VERY+long+and+truncated</segment>
 				<subtable>
 					<row>
 						<label>abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrst</label>
@@ -187,6 +191,7 @@
 				<revenue>1000</revenue>
 				<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 				<sum_daily_nb_users>0</sum_daily_nb_users>
+				<segment>customVariableName==Othercustom+value+which+should+be+truncated+abcdefghijklmnopqrstuvwxyz</segment>
 				<subtable>
 					<row>
 						<label>abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz</label>
@@ -212,6 +217,7 @@
 			<row>
 				<label>Language</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==Language</segment>
 				<subtable>
 					<row>
 						<label>FR</label>
@@ -224,6 +230,7 @@
 			<row>
 				<label>SET WITH EMPTY VALUE PAGE SCOPE</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==SET+WITH+EMPTY+VALUE+PAGE+SCOPE</segment>
 				<subtable>
 					<row>
 						<label>Value not defined</label>
diff --git a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchVisitorType__CustomVariables.getCustomVariables_day.xml b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchVisitorType__CustomVariables.getCustomVariables_day.xml
index 4a549e2004..304bb2fe65 100644
--- a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchVisitorType__CustomVariables.getCustomVariables_day.xml
+++ b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchVisitorType__CustomVariables.getCustomVariables_day.xml
@@ -19,6 +19,7 @@
 				</goals>
 				<nb_conversions>1</nb_conversions>
 				<revenue>0</revenue>
+				<segment>customVariableName==SET+WITH+EMPTY+VALUE</segment>
 				<subtable>
 					<row>
 						<label>Value not defined</label>
@@ -43,6 +44,7 @@
 			<row>
 				<label>Status user</label>
 				<nb_actions>3</nb_actions>
+				<segment>customVariableName==Status+user</segment>
 				<subtable>
 					<row>
 						<label>looking at &quot;profile page&quot;</label>
@@ -73,6 +75,7 @@
 				</goals>
 				<nb_conversions>1</nb_conversions>
 				<revenue>0</revenue>
+				<segment>customVariableName==Value+will+be+VERY+long+and+truncated</segment>
 				<subtable>
 					<row>
 						<label>abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrst</label>
@@ -116,6 +119,7 @@
 				</goals>
 				<nb_conversions>2</nb_conversions>
 				<revenue>0</revenue>
+				<segment>customVariableName==VisitorType</segment>
 				<subtable>
 					<row>
 						<label>LoggedIn</label>
@@ -153,6 +157,7 @@
 			<row>
 				<label>Language</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==Language</segment>
 				<subtable>
 					<row>
 						<label>FR</label>
@@ -164,6 +169,7 @@
 			<row>
 				<label>SET WITH EMPTY VALUE PAGE SCOPE</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==SET+WITH+EMPTY+VALUE+PAGE+SCOPE</segment>
 				<subtable>
 					<row>
 						<label>Value not defined</label>
diff --git a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchVisitorType__CustomVariables.getCustomVariables_week.xml b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchVisitorType__CustomVariables.getCustomVariables_week.xml
index 28956c8523..c4f92b8e6b 100644
--- a/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchVisitorType__CustomVariables.getCustomVariables_week.xml
+++ b/tests/PHPUnit/System/expected/test_twoVisitsWithCustomVariables_segmentMatchVisitorType__CustomVariables.getCustomVariables_week.xml
@@ -20,6 +20,7 @@
 				<revenue>0</revenue>
 				<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 				<sum_daily_nb_users>0</sum_daily_nb_users>
+				<segment>customVariableName==SET+WITH+EMPTY+VALUE</segment>
 				<subtable>
 					<row>
 						<label>Value not defined</label>
@@ -45,6 +46,7 @@
 			<row>
 				<label>Status user</label>
 				<nb_actions>3</nb_actions>
+				<segment>customVariableName==Status+user</segment>
 				<subtable>
 					<row>
 						<label>looking at &quot;profile page&quot;</label>
@@ -78,6 +80,7 @@
 				<revenue>0</revenue>
 				<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 				<sum_daily_nb_users>0</sum_daily_nb_users>
+				<segment>customVariableName==Value+will+be+VERY+long+and+truncated</segment>
 				<subtable>
 					<row>
 						<label>abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrstuvwxyz----abcdefghijklmnopqrst</label>
@@ -123,6 +126,7 @@
 				<revenue>0</revenue>
 				<sum_daily_nb_uniq_visitors>1</sum_daily_nb_uniq_visitors>
 				<sum_daily_nb_users>0</sum_daily_nb_users>
+				<segment>customVariableName==VisitorType</segment>
 				<subtable>
 					<row>
 						<label>LoggedIn</label>
@@ -161,6 +165,7 @@
 			<row>
 				<label>Language</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==Language</segment>
 				<subtable>
 					<row>
 						<label>FR</label>
@@ -173,6 +178,7 @@
 			<row>
 				<label>SET WITH EMPTY VALUE PAGE SCOPE</label>
 				<nb_actions>1</nb_actions>
+				<segment>customVariableName==SET+WITH+EMPTY+VALUE+PAGE+SCOPE</segment>
 				<subtable>
 					<row>
 						<label>Value not defined</label>
-- 
GitLab