From 17b6bbce675a72ed49d7f0acf3f249c36eff90be Mon Sep 17 00:00:00 2001
From: benakamoorthi <benaka.moorthi@gmail.com>
Date: Sun, 20 May 2012 03:45:21 +0000
Subject: [PATCH] Fixes #3055, fixed bug with CSV Renderer where column order
 was not kept constant when rendering DataTable_Arrays. Also modified
 OneVisitorTwoVisits test by adding more outlink actions and one CSV test.

git-svn-id: http://dev.piwik.org/svn/trunk@6276 59fd770c-687e-43c8-a1e3-f5a4ff64c105
---
 core/DataTable/Renderer/Csv.php               |  61 ++++++++++--------
 .../integration/OneVisitorTwoVisits.test.php  |  16 ++++-
 ...itorTwoVisits__Actions.getDownload_day.xml |   2 +-
 ...torTwoVisits__Actions.getDownloads_day.xml |   4 +-
 ...woVisits__Actions.getEntryPageUrls_day.xml |   2 +-
 ...TwoVisits__Actions.getExitPageUrls_day.xml |   2 +-
 ...sitorTwoVisits__Actions.getOutlink_day.xml |   4 +-
 ...itorTwoVisits__Actions.getOutlinks_day.xml |  24 +++++--
 ...orTwoVisits__Actions.getPageTitles_day.xml |   2 +-
 ...itorTwoVisits__Actions.getPageUrls_day.xml |   2 +-
 ...t_OneVisitorTwoVisits__Actions.get_day.xml |   4 +-
 ...isitorTwoVisits__MultiSites.getAll_day.xml |   2 +-
 ...torTwoVisits__Provider.getProvider_day.xml |   4 +-
 ...TwoVisits__Referers.getRefererType_day.xml |   4 +-
 ...torTwoVisits__Referers.getWebsites_day.xml |   8 +--
 ...woVisits__UserCountry.getContinent_day.xml |   4 +-
 ...rTwoVisits__UserCountry.getCountry_day.xml |   4 +-
 ...isits__UserSettings.getBrowserType_day.xml |   4 +-
 ...TwoVisits__UserSettings.getBrowser_day.xml |   4 +-
 ...its__UserSettings.getConfiguration_day.xml |   4 +-
 ...sitorTwoVisits__UserSettings.getOS_day.xml |   4 +-
 ...Visits__UserSettings.getResolution_day.xml |   4 +-
 ...Visits__UserSettings.getWideScreen_day.xml |   4 +-
 ...me.getVisitInformationPerLocalTime_day.xml |   4 +-
 ...e.getVisitInformationPerServerTime_day.xml |   4 +-
 ...rInterest.getNumberOfVisitsPerPage_day.xml |   4 +-
 ...woVisits__VisitsSummary.getActions_day.xml |   2 +-
 ...isits__VisitsSummary.getMaxActions_day.xml |   2 +-
 ...isitorTwoVisits__VisitsSummary.get_day.xml |   6 +-
 ...OneVisitorTwoVisits_csv__API.get_month.csv | Bin 0 -> 1672 bytes
 ...CookieSupport__Actions.getDownload_day.xml |   2 +-
 ...ookieSupport__Actions.getDownloads_day.xml |   4 +-
 ...eSupport__Actions.getEntryPageUrls_day.xml |   2 +-
 ...ieSupport__Actions.getExitPageUrls_day.xml |   2 +-
 ...hCookieSupport__Actions.getOutlink_day.xml |   4 +-
 ...CookieSupport__Actions.getOutlinks_day.xml |  24 +++++--
 ...okieSupport__Actions.getPageTitles_day.xml |   2 +-
 ...CookieSupport__Actions.getPageUrls_day.xml |   2 +-
 ...its_withCookieSupport__Actions.get_day.xml |   4 +-
 ...Support__Live.getLastVisitsDetails_day.xml |  30 +++++++--
 ...ookieSupport__Provider.getProvider_day.xml |   4 +-
 ...ieSupport__Referers.getRefererType_day.xml |   4 +-
 ...ookieSupport__Referers.getWebsites_day.xml |   8 +--
 ...eSupport__UserCountry.getContinent_day.xml |   4 +-
 ...kieSupport__UserCountry.getCountry_day.xml |   4 +-
 ...pport__UserSettings.getBrowserType_day.xml |   4 +-
 ...ieSupport__UserSettings.getBrowser_day.xml |   4 +-
 ...ort__UserSettings.getConfiguration_day.xml |   4 +-
 ...hCookieSupport__UserSettings.getOS_day.xml |   4 +-
 ...upport__UserSettings.getResolution_day.xml |   4 +-
 ...upport__UserSettings.getWideScreen_day.xml |   4 +-
 ...me.getVisitInformationPerLocalTime_day.xml |   4 +-
 ...e.getVisitInformationPerServerTime_day.xml |   4 +-
 ...rInterest.getNumberOfVisitsPerPage_day.xml |   4 +-
 ...eSupport__VisitsSummary.getActions_day.xml |   2 +-
 ...pport__VisitsSummary.getMaxActions_day.xml |   2 +-
 ...thCookieSupport__VisitsSummary.get_day.xml |   6 +-
 57 files changed, 205 insertions(+), 136 deletions(-)
 create mode 100755 tests/integration/expected/test_OneVisitorTwoVisits_csv__API.get_month.csv

diff --git a/core/DataTable/Renderer/Csv.php b/core/DataTable/Renderer/Csv.php
index 41d13c9962..01cea0e5c2 100644
--- a/core/DataTable/Renderer/Csv.php
+++ b/core/DataTable/Renderer/Csv.php
@@ -93,25 +93,16 @@ class Piwik_DataTable_Renderer_Csv extends Piwik_DataTable_Renderer
 		$this->separator = $separator;
 	}
 	
-	protected function renderTable($table)
+	protected function renderTable($table, &$allColumns = array() )
 	{
 		if($table instanceof Piwik_DataTable_Array)
 		{
-			$str = $header = '';
-			$keyName = $table->getKeyName();
-			if ($this->translateColumnNames)
-			{
-				$keyName = $this->translateColumnName($keyName);
-			}
-			$prefixColumns = $keyName . $this->separator;
+			$str = '';
 			foreach($table->getArray() as $currentLinePrefix => $dataTable)
 			{
-				$returned = explode("\n",$this->renderTable($dataTable));
-				// get the columns names
-				if(empty($header))
-				{
-					$header = $returned[0];
-				}
+				$returned = explode("\n",$this->renderTable($dataTable, $allColumns));
+				
+				// get rid of the columns names
 				$returned = array_slice($returned,1);
 				
 				// case empty datatable we dont print anything in the CSV export
@@ -125,19 +116,21 @@ class Piwik_DataTable_Renderer_Csv extends Piwik_DataTable_Renderer
 					$str .= "\n" .  implode("\n", $returned);
 				}
 			}
-			if(!empty($header))
-			{
-				$str = $prefixColumns . $header . $str;
-			}
+			
+			// prepend table key to column list
+			$allColumns = array_merge(array($table->getKeyName() => true), $allColumns);
+			
+			// add header to output string
+			$str = $this->getHeaderLine(array_keys($allColumns)).$str;
 		}
 		else
 		{
-			$str = $this->renderDataTable($table);
+			$str = $this->renderDataTable($table, $allColumns);
 		}
 		return $str;
 	}
 	
-	protected function renderDataTable( $table )
+	protected function renderDataTable( $table, &$allColumns = array() )
 	{	
 		if($table instanceof Piwik_DataTable_Simple)
 		{
@@ -147,13 +140,16 @@ class Piwik_DataTable_Renderer_Csv extends Piwik_DataTable_Renderer
 				$columnNameToValue = $row->getColumns();
 				if(count($columnNameToValue) == 1)
 				{
+					// simple tables should only have one column, the value
+					$allColumns['value'] = true;
+					
 					$value = array_values($columnNameToValue);
 					$str = 'value' . $this->lineEnd . $this->formatValue($value[0]);
 					return $str;
 				}
 			}
 		}
-		$csv = $allColumns = array();
+		$csv = array();
 		foreach($table->getRows() as $row)
 		{
 			$csvRow = array();
@@ -256,13 +252,7 @@ class Piwik_DataTable_Renderer_Csv extends Piwik_DataTable_Renderer
 		else
 		{
 			// render row names
-			$keys = array_keys($allColumns);
-			if ($this->translateColumnNames)
-			{
-				$keys = $this->translateColumnNames($keys);
-			}
-			$str .= implode($this->separator, $keys);
-			$str .= $this->lineEnd;
+			$str .= $this->getHeaderLine(array_keys($allColumns)).$this->lineEnd;
 		}
 		
 		// we render the CSV
@@ -280,6 +270,21 @@ class Piwik_DataTable_Renderer_Csv extends Piwik_DataTable_Renderer
 		$str = substr($str, 0, -strlen($this->lineEnd));
 		return $str;
 	}
+	
+	/**
+	 * Returns the CSV header line for a set of metrics. Will translate columns if desired.
+	 * 
+	 * @param array $columnMetrics
+	 * @return array
+	 */
+	private function getHeaderLine( $columnMetrics )
+	{
+		if ($this->translateColumnNames)
+		{
+			$columnMetrics = $this->translateColumnNames($columnMetrics);
+		}
+		return implode($this->separator, $columnMetrics);
+	}
 
 	protected function formatValue($value)
 	{
diff --git a/tests/integration/OneVisitorTwoVisits.test.php b/tests/integration/OneVisitorTwoVisits.test.php
index 78a3c9ffc8..30548d9ffc 100755
--- a/tests/integration/OneVisitorTwoVisits.test.php
+++ b/tests/integration/OneVisitorTwoVisits.test.php
@@ -10,7 +10,7 @@ require_once PIWIK_INCLUDE_PATH . '/tests/integration/Integration.php';
  * This use case covers many simple tracking features.
  * - Tracking Goal by manual trigger, and URL matching, with custom revenue
  * - Tracking the same Goal twice only records it once
- * - Tracks 2 page views, a click and a file download
+ * - Tracks 4 page views: 3 clicks and a file download
  * - URLs parameters exclude is tested
  * - In a returning visit, tracks a Goal conversion 
  *   URL matching, with custom referer and keyword
@@ -24,8 +24,16 @@ class Test_Piwik_Integration_OneVisitorTwoVisits extends Test_Integration_Facade
 
 	public function getApiToTest()
 	{
+		$enExtraParam = array('expanded' => 1, 'flat' => 1, 'include_aggregate_rows' => 0, 'translateColumnNames' => 1);
 		return array(
 			array('all', array('idSite' => $this->idSite, 'date' => $this->dateTime)),
+			
+			// test API.get (for bug that incorrectly reorders columns of CSV output)
+			//   note: bug only affects rows after first
+			array('API.get', array('idSite' => $this->idSite, 'date' => '2009-10-01', 'format' => 'csv',
+								   'periods' => array('month'), 'setDateLastN' => true,
+								   'otherRequestParameters' => $enExtraParam, 'language' => 'en',
+								   'testSuffix' => '_csv')),
 		);
 	}
 
@@ -84,6 +92,12 @@ class Test_Piwik_Integration_OneVisitorTwoVisits extends Test_Integration_Facade
 		$t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.2)->getDatetime());
 		$this->checkResponse($t->doTrackAction( 'http://piwik.org/path/again/latest.zip', 'download' ));
 		
+		// Click on two more external links, one the same as before (5th & 6th actions)
+		$t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.22)->getDateTime());
+		$this->checkResponse($t->doTrackAction('http://outlinks.org/other_outlink', 'link'));
+		$t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.25)->getDateTime());
+		$this->checkResponse($t->doTrackAction('http://dev.piwik.org/svn', 'link'));
+		
 		// Create Goal 1: Triggered by JS, after 18 minutes
 		$idGoal = Piwik_Goals_API::getInstance()->addGoal($idSite, 'triggered js', 'manually', '', '');
 		$t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.3)->getDatetime());
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getDownload_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getDownload_day.xml
index d4805af215..32470e4bcb 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getDownload_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getDownload_day.xml
@@ -5,7 +5,7 @@
 		<nb_visits>1</nb_visits>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_hits>1</nb_hits>
-		<sum_time_spent>180</sum_time_spent>
+		<sum_time_spent>72</sum_time_spent>
 		<url>http://piwik.org/path/again/latest.zip</url>
 	</row>
 </result>
\ No newline at end of file
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getDownloads_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getDownloads_day.xml
index 59eee28a17..c064136f43 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getDownloads_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getDownloads_day.xml
@@ -4,14 +4,14 @@
 		<label>piwik.org</label>
 		<nb_visits>1</nb_visits>
 		<nb_hits>1</nb_hits>
-		<sum_time_spent>180</sum_time_spent>
+		<sum_time_spent>72</sum_time_spent>
 		<subtable>
 			<row>
 				<label>/path/again/latest.zip</label>
 				<nb_visits>1</nb_visits>
 				<nb_uniq_visitors>1</nb_uniq_visitors>
 				<nb_hits>1</nb_hits>
-				<sum_time_spent>180</sum_time_spent>
+				<sum_time_spent>72</sum_time_spent>
 				<url>http://piwik.org/path/again/latest.zip</url>
 			</row>
 		</subtable>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getEntryPageUrls_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getEntryPageUrls_day.xml
index 724b463fc9..838606a12e 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getEntryPageUrls_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getEntryPageUrls_day.xml
@@ -32,7 +32,7 @@
 		<sum_time_spent>180</sum_time_spent>
 		<entry_nb_uniq_visitors>1</entry_nb_uniq_visitors>
 		<entry_nb_visits>1</entry_nb_visits>
-		<entry_nb_actions>5</entry_nb_actions>
+		<entry_nb_actions>7</entry_nb_actions>
 		<entry_sum_visit_length>1621</entry_sum_visit_length>
 		<entry_bounce_count>0</entry_bounce_count>
 		<avg_time_on_page>180</avg_time_on_page>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getExitPageUrls_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getExitPageUrls_day.xml
index 724b463fc9..838606a12e 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getExitPageUrls_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getExitPageUrls_day.xml
@@ -32,7 +32,7 @@
 		<sum_time_spent>180</sum_time_spent>
 		<entry_nb_uniq_visitors>1</entry_nb_uniq_visitors>
 		<entry_nb_visits>1</entry_nb_visits>
-		<entry_nb_actions>5</entry_nb_actions>
+		<entry_nb_actions>7</entry_nb_actions>
 		<entry_sum_visit_length>1621</entry_sum_visit_length>
 		<entry_bounce_count>0</entry_bounce_count>
 		<avg_time_on_page>180</avg_time_on_page>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getOutlink_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getOutlink_day.xml
index f079748c37..5971863326 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getOutlink_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getOutlink_day.xml
@@ -4,8 +4,8 @@
 		<label>/svn</label>
 		<nb_visits>1</nb_visits>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
-		<nb_hits>1</nb_hits>
-		<sum_time_spent>360</sum_time_spent>
+		<nb_hits>2</nb_hits>
+		<sum_time_spent>540</sum_time_spent>
 		<url>http://dev.piwik.org/svn</url>
 	</row>
 </result>
\ No newline at end of file
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getOutlinks_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getOutlinks_day.xml
index cfb9e890ea..539d798e9b 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getOutlinks_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getOutlinks_day.xml
@@ -3,17 +3,33 @@
 	<row>
 		<label>dev.piwik.org</label>
 		<nb_visits>1</nb_visits>
-		<nb_hits>1</nb_hits>
-		<sum_time_spent>360</sum_time_spent>
+		<nb_hits>2</nb_hits>
+		<sum_time_spent>540</sum_time_spent>
 		<subtable>
 			<row>
 				<label>/svn</label>
 				<nb_visits>1</nb_visits>
 				<nb_uniq_visitors>1</nb_uniq_visitors>
-				<nb_hits>1</nb_hits>
-				<sum_time_spent>360</sum_time_spent>
+				<nb_hits>2</nb_hits>
+				<sum_time_spent>540</sum_time_spent>
 				<url>http://dev.piwik.org/svn</url>
 			</row>
 		</subtable>
 	</row>
+	<row>
+		<label>outlinks.org</label>
+		<nb_visits>1</nb_visits>
+		<nb_hits>1</nb_hits>
+		<sum_time_spent>108</sum_time_spent>
+		<subtable>
+			<row>
+				<label>/other_outlink</label>
+				<nb_visits>1</nb_visits>
+				<nb_uniq_visitors>1</nb_uniq_visitors>
+				<nb_hits>1</nb_hits>
+				<sum_time_spent>108</sum_time_spent>
+				<url>http://outlinks.org/other_outlink</url>
+			</row>
+		</subtable>
+	</row>
 </result>
\ No newline at end of file
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getPageTitles_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getPageTitles_day.xml
index e57dd376e5..4aff330ec5 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getPageTitles_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getPageTitles_day.xml
@@ -41,7 +41,7 @@
 		<sum_time_spent>180</sum_time_spent>
 		<entry_nb_uniq_visitors>1</entry_nb_uniq_visitors>
 		<entry_nb_visits>1</entry_nb_visits>
-		<entry_nb_actions>5</entry_nb_actions>
+		<entry_nb_actions>7</entry_nb_actions>
 		<entry_sum_visit_length>1621</entry_sum_visit_length>
 		<entry_bounce_count>0</entry_bounce_count>
 		<avg_time_on_page>180</avg_time_on_page>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getPageUrls_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getPageUrls_day.xml
index 724b463fc9..838606a12e 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getPageUrls_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.getPageUrls_day.xml
@@ -32,7 +32,7 @@
 		<sum_time_spent>180</sum_time_spent>
 		<entry_nb_uniq_visitors>1</entry_nb_uniq_visitors>
 		<entry_nb_visits>1</entry_nb_visits>
-		<entry_nb_actions>5</entry_nb_actions>
+		<entry_nb_actions>7</entry_nb_actions>
 		<entry_sum_visit_length>1621</entry_sum_visit_length>
 		<entry_bounce_count>0</entry_bounce_count>
 		<avg_time_on_page>180</avg_time_on_page>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.get_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.get_day.xml
index c8ea778d2d..e0f88f84f4 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__Actions.get_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__Actions.get_day.xml
@@ -4,6 +4,6 @@
 	<nb_uniq_pageviews>4</nb_uniq_pageviews>
 	<nb_downloads>1</nb_downloads>
 	<nb_uniq_downloads>1</nb_uniq_downloads>
-	<nb_outlinks>1</nb_outlinks>
-	<nb_uniq_outlinks>1</nb_uniq_outlinks>
+	<nb_outlinks>3</nb_outlinks>
+	<nb_uniq_outlinks>2</nb_uniq_outlinks>
 </result>
\ No newline at end of file
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__MultiSites.getAll_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__MultiSites.getAll_day.xml
index 4fa2d13b1e..4ed44e2fa9 100755
--- a/tests/integration/expected/test_OneVisitorTwoVisits__MultiSites.getAll_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__MultiSites.getAll_day.xml
@@ -3,7 +3,7 @@
 	<row>
 		<label>new name</label>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
+		<nb_actions>8</nb_actions>
 		<revenue>43</revenue>
 		<visits_evolution>100%</visits_evolution>
 		<actions_evolution>100%</actions_evolution>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__Provider.getProvider_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__Provider.getProvider_day.xml
index 7ecac0736b..7b9b086c44 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__Provider.getProvider_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__Provider.getProvider_day.xml
@@ -4,8 +4,8 @@
 		<label>Unknown</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__Referers.getRefererType_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__Referers.getRefererType_day.xml
index f0f56862c2..720d7da208 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__Referers.getRefererType_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__Referers.getRefererType_day.xml
@@ -22,8 +22,8 @@
 		<label>Websites</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>1</nb_visits>
-		<nb_actions>5</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>7</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>0</bounce_count>
 		<goals>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__Referers.getWebsites_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__Referers.getWebsites_day.xml
index ed6b1a09d8..2450421efd 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__Referers.getWebsites_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__Referers.getWebsites_day.xml
@@ -4,8 +4,8 @@
 		<label>referer.com</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>1</nb_visits>
-		<nb_actions>5</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>7</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>0</bounce_count>
 		<goals>
@@ -22,8 +22,8 @@
 				<label>http://referer.com/page.htm?param=valuewith some spaces</label>
 				<nb_uniq_visitors>1</nb_uniq_visitors>
 				<nb_visits>1</nb_visits>
-				<nb_actions>5</nb_actions>
-				<max_actions>5</max_actions>
+				<nb_actions>7</nb_actions>
+				<max_actions>7</max_actions>
 				<sum_visit_length>1621</sum_visit_length>
 				<bounce_count>0</bounce_count>
 				<nb_visits_converted>1</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__UserCountry.getContinent_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__UserCountry.getContinent_day.xml
index c24824e4ed..280b7fd6fc 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__UserCountry.getContinent_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__UserCountry.getContinent_day.xml
@@ -4,8 +4,8 @@
 		<label>Europe</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<goals>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__UserCountry.getCountry_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__UserCountry.getCountry_day.xml
index ff7c8cc867..d85b8bf99b 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__UserCountry.getCountry_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__UserCountry.getCountry_day.xml
@@ -4,8 +4,8 @@
 		<label>France</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<goals>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getBrowserType_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getBrowserType_day.xml
index af2ac94166..6d13aaf736 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getBrowserType_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getBrowserType_day.xml
@@ -4,8 +4,8 @@
 		<label>Gecko (Firefox)</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getBrowser_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getBrowser_day.xml
index c313b3c92d..8210497910 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getBrowser_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getBrowser_day.xml
@@ -4,8 +4,8 @@
 		<label>Firefox 3.6</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getConfiguration_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getConfiguration_day.xml
index 03655ef142..1a63f1933a 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getConfiguration_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getConfiguration_day.xml
@@ -4,8 +4,8 @@
 		<label>Windows XP / Firefox / 1024x768</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getOS_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getOS_day.xml
index 423e94d2fd..32ec517b60 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getOS_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getOS_day.xml
@@ -4,8 +4,8 @@
 		<label>Windows XP</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getResolution_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getResolution_day.xml
index 3036d28871..ede209680d 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getResolution_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getResolution_day.xml
@@ -4,8 +4,8 @@
 		<label>1024x768</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getWideScreen_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getWideScreen_day.xml
index e294734cdc..f1acb38cb9 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getWideScreen_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__UserSettings.getWideScreen_day.xml
@@ -4,8 +4,8 @@
 		<label>Normal</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__VisitTime.getVisitInformationPerLocalTime_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__VisitTime.getVisitInformationPerLocalTime_day.xml
index aad9493139..b95f277bfc 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__VisitTime.getVisitInformationPerLocalTime_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__VisitTime.getVisitInformationPerLocalTime_day.xml
@@ -124,8 +124,8 @@
 		<label>12h</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__VisitTime.getVisitInformationPerServerTime_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__VisitTime.getVisitInformationPerServerTime_day.xml
index c76e43b97a..5f96c55a5b 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__VisitTime.getVisitInformationPerServerTime_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__VisitTime.getVisitInformationPerServerTime_day.xml
@@ -114,8 +114,8 @@
 		<label>11h</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>1</nb_visits>
-		<nb_actions>5</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>7</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>0</bounce_count>
 		<goals>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__VisitorInterest.getNumberOfVisitsPerPage_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__VisitorInterest.getNumberOfVisitsPerPage_day.xml
index 1cb496b6ec..30a3a7f161 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__VisitorInterest.getNumberOfVisitsPerPage_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__VisitorInterest.getNumberOfVisitsPerPage_day.xml
@@ -18,11 +18,11 @@
 	</row>
 	<row>
 		<label>5 pages</label>
-		<nb_visits>1</nb_visits>
+		<nb_visits>0</nb_visits>
 	</row>
 	<row>
 		<label>6-7 pages</label>
-		<nb_visits>0</nb_visits>
+		<nb_visits>1</nb_visits>
 	</row>
 	<row>
 		<label>8-10 pages</label>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__VisitsSummary.getActions_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__VisitsSummary.getActions_day.xml
index 3cc2819f51..e52ca0ecb1 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__VisitsSummary.getActions_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__VisitsSummary.getActions_day.xml
@@ -1,2 +1,2 @@
 <?xml version="1.0" encoding="utf-8" ?>
-<result>6</result>
\ No newline at end of file
+<result>8</result>
\ No newline at end of file
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__VisitsSummary.getMaxActions_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__VisitsSummary.getMaxActions_day.xml
index 17feb622cc..773871bab0 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__VisitsSummary.getMaxActions_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__VisitsSummary.getMaxActions_day.xml
@@ -1,2 +1,2 @@
 <?xml version="1.0" encoding="utf-8" ?>
-<result>5</result>
\ No newline at end of file
+<result>7</result>
\ No newline at end of file
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits__VisitsSummary.get_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits__VisitsSummary.get_day.xml
index 6437d492e5..40498bf45d 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits__VisitsSummary.get_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits__VisitsSummary.get_day.xml
@@ -2,12 +2,12 @@
 <result>
 	<nb_uniq_visitors>1</nb_uniq_visitors>
 	<nb_visits>2</nb_visits>
-	<nb_actions>6</nb_actions>
+	<nb_actions>8</nb_actions>
 	<nb_visits_converted>2</nb_visits_converted>
 	<bounce_count>1</bounce_count>
 	<sum_visit_length>1621</sum_visit_length>
-	<max_actions>5</max_actions>
+	<max_actions>7</max_actions>
 	<bounce_rate>50%</bounce_rate>
-	<nb_actions_per_visit>3</nb_actions_per_visit>
+	<nb_actions_per_visit>4</nb_actions_per_visit>
 	<avg_time_on_site>811</avg_time_on_site>
 </result>
\ No newline at end of file
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_csv__API.get_month.csv b/tests/integration/expected/test_OneVisitorTwoVisits_csv__API.get_month.csv
new file mode 100755
index 0000000000000000000000000000000000000000..01bc3dbb74b6d0798a458625e7648d5f4ba05771
GIT binary patch
literal 1672
zcmcgq!A^rf6r8hPu@@6fs1ekt$0}E&X`*+eT8Wk_(4s%D&Ma;bO0AcY=9S%j^WMDK
zov+Uj5ehuO!!1%Ic*C4Kg9X<)qreOqS03(`C)y1WGnX)%+H7-g@X9V3`_xq)E{L8J
zA6tgel6gqB2@V=)gOJ$FVk#DcJ@TbQ<*bh_^O);>PIE=vJF`>POo@mZ)0v+-&DzxF
zVZ@WdGD&^PIeyQ)s?^{fAH@8p&Z$~eGQ*>ta#NqSW@+udMZ=DIsZAX#MQ*ZnulBdP
zwpX%_J6!e8rG2plvGP;xoZ2Bdr!Sc)@Wj<ReAl^DJ0ELyv7~%e`TB;Li9JjBUs|^|
zz21cgIc>=vFZ@Q3&)TZH5ZB}^SR*Grcht1=I|y*d-#G^G`SrFKO)kGjuAm1l-QIxF
zhc3s}r>-O3p|pwfjB(63q267)_igT!Yhm0SXwC}ZPE@U^GU}qf>ZNeCItx(w#c5T3
Hd;a_e4nFN(

literal 0
HcmV?d00001

diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getDownload_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getDownload_day.xml
index d4805af215..32470e4bcb 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getDownload_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getDownload_day.xml
@@ -5,7 +5,7 @@
 		<nb_visits>1</nb_visits>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_hits>1</nb_hits>
-		<sum_time_spent>180</sum_time_spent>
+		<sum_time_spent>72</sum_time_spent>
 		<url>http://piwik.org/path/again/latest.zip</url>
 	</row>
 </result>
\ No newline at end of file
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getDownloads_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getDownloads_day.xml
index 59eee28a17..c064136f43 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getDownloads_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getDownloads_day.xml
@@ -4,14 +4,14 @@
 		<label>piwik.org</label>
 		<nb_visits>1</nb_visits>
 		<nb_hits>1</nb_hits>
-		<sum_time_spent>180</sum_time_spent>
+		<sum_time_spent>72</sum_time_spent>
 		<subtable>
 			<row>
 				<label>/path/again/latest.zip</label>
 				<nb_visits>1</nb_visits>
 				<nb_uniq_visitors>1</nb_uniq_visitors>
 				<nb_hits>1</nb_hits>
-				<sum_time_spent>180</sum_time_spent>
+				<sum_time_spent>72</sum_time_spent>
 				<url>http://piwik.org/path/again/latest.zip</url>
 			</row>
 		</subtable>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getEntryPageUrls_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getEntryPageUrls_day.xml
index 724b463fc9..838606a12e 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getEntryPageUrls_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getEntryPageUrls_day.xml
@@ -32,7 +32,7 @@
 		<sum_time_spent>180</sum_time_spent>
 		<entry_nb_uniq_visitors>1</entry_nb_uniq_visitors>
 		<entry_nb_visits>1</entry_nb_visits>
-		<entry_nb_actions>5</entry_nb_actions>
+		<entry_nb_actions>7</entry_nb_actions>
 		<entry_sum_visit_length>1621</entry_sum_visit_length>
 		<entry_bounce_count>0</entry_bounce_count>
 		<avg_time_on_page>180</avg_time_on_page>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getExitPageUrls_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getExitPageUrls_day.xml
index 724b463fc9..838606a12e 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getExitPageUrls_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getExitPageUrls_day.xml
@@ -32,7 +32,7 @@
 		<sum_time_spent>180</sum_time_spent>
 		<entry_nb_uniq_visitors>1</entry_nb_uniq_visitors>
 		<entry_nb_visits>1</entry_nb_visits>
-		<entry_nb_actions>5</entry_nb_actions>
+		<entry_nb_actions>7</entry_nb_actions>
 		<entry_sum_visit_length>1621</entry_sum_visit_length>
 		<entry_bounce_count>0</entry_bounce_count>
 		<avg_time_on_page>180</avg_time_on_page>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getOutlink_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getOutlink_day.xml
index f079748c37..5971863326 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getOutlink_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getOutlink_day.xml
@@ -4,8 +4,8 @@
 		<label>/svn</label>
 		<nb_visits>1</nb_visits>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
-		<nb_hits>1</nb_hits>
-		<sum_time_spent>360</sum_time_spent>
+		<nb_hits>2</nb_hits>
+		<sum_time_spent>540</sum_time_spent>
 		<url>http://dev.piwik.org/svn</url>
 	</row>
 </result>
\ No newline at end of file
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getOutlinks_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getOutlinks_day.xml
index cfb9e890ea..539d798e9b 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getOutlinks_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getOutlinks_day.xml
@@ -3,17 +3,33 @@
 	<row>
 		<label>dev.piwik.org</label>
 		<nb_visits>1</nb_visits>
-		<nb_hits>1</nb_hits>
-		<sum_time_spent>360</sum_time_spent>
+		<nb_hits>2</nb_hits>
+		<sum_time_spent>540</sum_time_spent>
 		<subtable>
 			<row>
 				<label>/svn</label>
 				<nb_visits>1</nb_visits>
 				<nb_uniq_visitors>1</nb_uniq_visitors>
-				<nb_hits>1</nb_hits>
-				<sum_time_spent>360</sum_time_spent>
+				<nb_hits>2</nb_hits>
+				<sum_time_spent>540</sum_time_spent>
 				<url>http://dev.piwik.org/svn</url>
 			</row>
 		</subtable>
 	</row>
+	<row>
+		<label>outlinks.org</label>
+		<nb_visits>1</nb_visits>
+		<nb_hits>1</nb_hits>
+		<sum_time_spent>108</sum_time_spent>
+		<subtable>
+			<row>
+				<label>/other_outlink</label>
+				<nb_visits>1</nb_visits>
+				<nb_uniq_visitors>1</nb_uniq_visitors>
+				<nb_hits>1</nb_hits>
+				<sum_time_spent>108</sum_time_spent>
+				<url>http://outlinks.org/other_outlink</url>
+			</row>
+		</subtable>
+	</row>
 </result>
\ No newline at end of file
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getPageTitles_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getPageTitles_day.xml
index e57dd376e5..4aff330ec5 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getPageTitles_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getPageTitles_day.xml
@@ -41,7 +41,7 @@
 		<sum_time_spent>180</sum_time_spent>
 		<entry_nb_uniq_visitors>1</entry_nb_uniq_visitors>
 		<entry_nb_visits>1</entry_nb_visits>
-		<entry_nb_actions>5</entry_nb_actions>
+		<entry_nb_actions>7</entry_nb_actions>
 		<entry_sum_visit_length>1621</entry_sum_visit_length>
 		<entry_bounce_count>0</entry_bounce_count>
 		<avg_time_on_page>180</avg_time_on_page>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getPageUrls_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getPageUrls_day.xml
index 724b463fc9..838606a12e 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getPageUrls_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.getPageUrls_day.xml
@@ -32,7 +32,7 @@
 		<sum_time_spent>180</sum_time_spent>
 		<entry_nb_uniq_visitors>1</entry_nb_uniq_visitors>
 		<entry_nb_visits>1</entry_nb_visits>
-		<entry_nb_actions>5</entry_nb_actions>
+		<entry_nb_actions>7</entry_nb_actions>
 		<entry_sum_visit_length>1621</entry_sum_visit_length>
 		<entry_bounce_count>0</entry_bounce_count>
 		<avg_time_on_page>180</avg_time_on_page>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.get_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.get_day.xml
index c8ea778d2d..e0f88f84f4 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.get_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Actions.get_day.xml
@@ -4,6 +4,6 @@
 	<nb_uniq_pageviews>4</nb_uniq_pageviews>
 	<nb_downloads>1</nb_downloads>
 	<nb_uniq_downloads>1</nb_uniq_downloads>
-	<nb_outlinks>1</nb_outlinks>
-	<nb_uniq_outlinks>1</nb_uniq_outlinks>
+	<nb_outlinks>3</nb_outlinks>
+	<nb_uniq_outlinks>2</nb_uniq_outlinks>
 </result>
\ No newline at end of file
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Live.getLastVisitsDetails_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Live.getLastVisitsDetails_day.xml
index 48b191fd4a..fffeb83b89 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Live.getLastVisitsDetails_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Live.getLastVisitsDetails_day.xml
@@ -17,7 +17,7 @@
 				<type>goal</type>
 				<goalName>matching purchase.htm</goalName>
 				<revenue>1</revenue>
-				<goalPageId>6</goalPageId>
+				<goalPageId>8</goalPageId>
 				
 				<url>http://example.org/store/purchase.htm</url>
 				<icon>themes/default/images/goal.png</icon>
@@ -26,8 +26,8 @@
 				<type>action</type>
 				<url>http://example.org/store/purchase.htm</url>
 				<pageTitle>Checkout/Purchasing...</pageTitle>
-				<pageIdAction>10</pageIdAction>
-				<pageId>6</pageId>
+				<pageIdAction>11</pageIdAction>
+				<pageId>8</pageId>
 				
 				<icon />
 			</row>
@@ -99,7 +99,7 @@
 		<visitConvertedIcon>themes/default/images/goal.png</visitConvertedIcon>
 		<visitEcommerceStatus>none</visitEcommerceStatus>
 		<visitEcommerceStatusIcon />
-		<actions>5</actions>
+		<actions>7</actions>
 		<actionDetails>
 			<row>
 				<type>action</type>
@@ -137,6 +137,24 @@
 				
 				<icon>themes/default/images/download.png</icon>
 			</row>
+			<row>
+				<type>outlink</type>
+				<url>http://outlinks.org/other_outlink</url>
+				<pageTitle />
+				<pageIdAction>7</pageIdAction>
+				<pageId>5</pageId>
+				
+				<icon>themes/default/images/link.gif</icon>
+			</row>
+			<row>
+				<type>outlink</type>
+				<url>http://dev.piwik.org/svn</url>
+				<pageTitle />
+				<pageIdAction>5</pageIdAction>
+				<pageId>6</pageId>
+				
+				<icon>themes/default/images/link.gif</icon>
+			</row>
 			<row>
 				<type>goal</type>
 				<goalName>triggered js</goalName>
@@ -150,8 +168,8 @@
 				<type>action</type>
 				<url>http://example.org/index.htm</url>
 				<pageTitle>Looking at homepage (again)...</pageTitle>
-				<pageIdAction>8</pageIdAction>
-				<pageId>5</pageId>
+				<pageIdAction>9</pageIdAction>
+				<pageId>7</pageId>
 				
 				<icon />
 			</row>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Provider.getProvider_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Provider.getProvider_day.xml
index 7ecac0736b..7b9b086c44 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Provider.getProvider_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Provider.getProvider_day.xml
@@ -4,8 +4,8 @@
 		<label>Unknown</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Referers.getRefererType_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Referers.getRefererType_day.xml
index f0f56862c2..720d7da208 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Referers.getRefererType_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Referers.getRefererType_day.xml
@@ -22,8 +22,8 @@
 		<label>Websites</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>1</nb_visits>
-		<nb_actions>5</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>7</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>0</bounce_count>
 		<goals>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Referers.getWebsites_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Referers.getWebsites_day.xml
index ed6b1a09d8..2450421efd 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Referers.getWebsites_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__Referers.getWebsites_day.xml
@@ -4,8 +4,8 @@
 		<label>referer.com</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>1</nb_visits>
-		<nb_actions>5</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>7</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>0</bounce_count>
 		<goals>
@@ -22,8 +22,8 @@
 				<label>http://referer.com/page.htm?param=valuewith some spaces</label>
 				<nb_uniq_visitors>1</nb_uniq_visitors>
 				<nb_visits>1</nb_visits>
-				<nb_actions>5</nb_actions>
-				<max_actions>5</max_actions>
+				<nb_actions>7</nb_actions>
+				<max_actions>7</max_actions>
 				<sum_visit_length>1621</sum_visit_length>
 				<bounce_count>0</bounce_count>
 				<nb_visits_converted>1</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserCountry.getContinent_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserCountry.getContinent_day.xml
index c24824e4ed..280b7fd6fc 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserCountry.getContinent_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserCountry.getContinent_day.xml
@@ -4,8 +4,8 @@
 		<label>Europe</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<goals>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserCountry.getCountry_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserCountry.getCountry_day.xml
index ff7c8cc867..d85b8bf99b 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserCountry.getCountry_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserCountry.getCountry_day.xml
@@ -4,8 +4,8 @@
 		<label>France</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<goals>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getBrowserType_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getBrowserType_day.xml
index af2ac94166..6d13aaf736 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getBrowserType_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getBrowserType_day.xml
@@ -4,8 +4,8 @@
 		<label>Gecko (Firefox)</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getBrowser_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getBrowser_day.xml
index c313b3c92d..8210497910 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getBrowser_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getBrowser_day.xml
@@ -4,8 +4,8 @@
 		<label>Firefox 3.6</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getConfiguration_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getConfiguration_day.xml
index 03655ef142..1a63f1933a 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getConfiguration_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getConfiguration_day.xml
@@ -4,8 +4,8 @@
 		<label>Windows XP / Firefox / 1024x768</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getOS_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getOS_day.xml
index 423e94d2fd..32ec517b60 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getOS_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getOS_day.xml
@@ -4,8 +4,8 @@
 		<label>Windows XP</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getResolution_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getResolution_day.xml
index 3036d28871..ede209680d 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getResolution_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getResolution_day.xml
@@ -4,8 +4,8 @@
 		<label>1024x768</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getWideScreen_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getWideScreen_day.xml
index e294734cdc..f1acb38cb9 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getWideScreen_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__UserSettings.getWideScreen_day.xml
@@ -4,8 +4,8 @@
 		<label>Normal</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitTime.getVisitInformationPerLocalTime_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitTime.getVisitInformationPerLocalTime_day.xml
index aad9493139..b95f277bfc 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitTime.getVisitInformationPerLocalTime_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitTime.getVisitInformationPerLocalTime_day.xml
@@ -124,8 +124,8 @@
 		<label>12h</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>2</nb_visits>
-		<nb_actions>6</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>8</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>1</bounce_count>
 		<nb_visits_converted>2</nb_visits_converted>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitTime.getVisitInformationPerServerTime_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitTime.getVisitInformationPerServerTime_day.xml
index c76e43b97a..5f96c55a5b 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitTime.getVisitInformationPerServerTime_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitTime.getVisitInformationPerServerTime_day.xml
@@ -114,8 +114,8 @@
 		<label>11h</label>
 		<nb_uniq_visitors>1</nb_uniq_visitors>
 		<nb_visits>1</nb_visits>
-		<nb_actions>5</nb_actions>
-		<max_actions>5</max_actions>
+		<nb_actions>7</nb_actions>
+		<max_actions>7</max_actions>
 		<sum_visit_length>1621</sum_visit_length>
 		<bounce_count>0</bounce_count>
 		<goals>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitorInterest.getNumberOfVisitsPerPage_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitorInterest.getNumberOfVisitsPerPage_day.xml
index 1cb496b6ec..30a3a7f161 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitorInterest.getNumberOfVisitsPerPage_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitorInterest.getNumberOfVisitsPerPage_day.xml
@@ -18,11 +18,11 @@
 	</row>
 	<row>
 		<label>5 pages</label>
-		<nb_visits>1</nb_visits>
+		<nb_visits>0</nb_visits>
 	</row>
 	<row>
 		<label>6-7 pages</label>
-		<nb_visits>0</nb_visits>
+		<nb_visits>1</nb_visits>
 	</row>
 	<row>
 		<label>8-10 pages</label>
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitsSummary.getActions_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitsSummary.getActions_day.xml
index 3cc2819f51..e52ca0ecb1 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitsSummary.getActions_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitsSummary.getActions_day.xml
@@ -1,2 +1,2 @@
 <?xml version="1.0" encoding="utf-8" ?>
-<result>6</result>
\ No newline at end of file
+<result>8</result>
\ No newline at end of file
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitsSummary.getMaxActions_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitsSummary.getMaxActions_day.xml
index 17feb622cc..773871bab0 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitsSummary.getMaxActions_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitsSummary.getMaxActions_day.xml
@@ -1,2 +1,2 @@
 <?xml version="1.0" encoding="utf-8" ?>
-<result>5</result>
\ No newline at end of file
+<result>7</result>
\ No newline at end of file
diff --git a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitsSummary.get_day.xml b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitsSummary.get_day.xml
index 6437d492e5..40498bf45d 100644
--- a/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitsSummary.get_day.xml
+++ b/tests/integration/expected/test_OneVisitorTwoVisits_withCookieSupport__VisitsSummary.get_day.xml
@@ -2,12 +2,12 @@
 <result>
 	<nb_uniq_visitors>1</nb_uniq_visitors>
 	<nb_visits>2</nb_visits>
-	<nb_actions>6</nb_actions>
+	<nb_actions>8</nb_actions>
 	<nb_visits_converted>2</nb_visits_converted>
 	<bounce_count>1</bounce_count>
 	<sum_visit_length>1621</sum_visit_length>
-	<max_actions>5</max_actions>
+	<max_actions>7</max_actions>
 	<bounce_rate>50%</bounce_rate>
-	<nb_actions_per_visit>3</nb_actions_per_visit>
+	<nb_actions_per_visit>4</nb_actions_per_visit>
 	<avg_time_on_site>811</avg_time_on_site>
 </result>
\ No newline at end of file
-- 
GitLab