Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Goals')
-rw-r--r--plugins/Goals/API.php37
-rw-r--r--plugins/Goals/Controller.php218
-rw-r--r--plugins/Goals/Goals.php30
-rw-r--r--plugins/Goals/templates/GoalForm.js111
-rw-r--r--plugins/Goals/templates/add_edit_goal.tpl68
-rw-r--r--plugins/Goals/templates/add_new_goal.tpl4
-rw-r--r--plugins/Goals/templates/form_add_goal.tpl149
-rw-r--r--plugins/Goals/templates/goals.css40
-rw-r--r--plugins/Goals/templates/list_goal_edit.tpl39
-rw-r--r--plugins/Goals/templates/list_top_segment.tpl11
-rw-r--r--plugins/Goals/templates/overview.tpl41
-rw-r--r--plugins/Goals/templates/release_notes.tpl36
-rw-r--r--plugins/Goals/templates/single_goal.tpl46
-rw-r--r--plugins/Goals/templates/table_by_segment.tpl72
-rw-r--r--plugins/Goals/templates/title_and_evolution_graph.tpl12
15 files changed, 539 insertions, 375 deletions
diff --git a/plugins/Goals/API.php b/plugins/Goals/API.php
index 5ed95fd68b..6f00d96868 100644
--- a/plugins/Goals/API.php
+++ b/plugins/Goals/API.php
@@ -27,7 +27,7 @@ class Piwik_Goals_API
return self::$instance;
}
- static public function getGoals( $idSite )
+ public function getGoals( $idSite )
{
$goals = Piwik_FetchAll("SELECT *
FROM ".Piwik_Common::prefixTable('goal')."
@@ -53,16 +53,16 @@ class Piwik_Goals_API
// save in db
$db = Zend_Registry::get('db');
$idGoal = $db->fetchOne("SELECT max(idgoal) + 1
- FROM ".Piwik::prefixTable('goal')."
+ FROM ".Piwik_Common::prefixTable('goal')."
WHERE idsite = ?", $idSite);
if($idGoal == false)
{
$idGoal = 1;
}
- self::checkPatternIsValid($patternType, $pattern);
- $name = self::checkName($name);
- $pattern = self::checkPattern($pattern);
- $db->insert(Piwik::prefixTable('goal'),
+ $this->checkPatternIsValid($patternType, $pattern);
+ $name = $this->checkName($name);
+ $pattern = $this->checkPattern($pattern);
+ $db->insert(Piwik_Common::prefixTable('goal'),
array(
'idsite' => $idSite,
'idgoal' => $idGoal,
@@ -81,10 +81,10 @@ class Piwik_Goals_API
public function updateGoal( $idSite, $idGoal, $name, $matchAttribute, $pattern, $patternType, $caseSensitive, $revenue )
{
Piwik::checkUserHasAdminAccess($idSite);
- $name = self::checkName($name);
- $pattern = self::checkPattern($pattern);
- self::checkPatternIsValid($patternType, $pattern);
- Zend_Registry::get('db')->update( Piwik::prefixTable('goal'),
+ $name = $this->checkName($name);
+ $pattern = $this->checkPattern($pattern);
+ $this->checkPatternIsValid($patternType, $pattern);
+ Zend_Registry::get('db')->update( Piwik_Common::prefixTable('goal'),
array(
'name' => $name,
'match_attribute' => $matchAttribute,
@@ -103,8 +103,7 @@ class Piwik_Goals_API
if($patternType == 'exact'
&& substr($pattern, 0, 4) != 'http')
{
- throw new Exception("If you choose 'exact match', the matching string must be a
- URL starting with http:// or https://. For example, 'http://www.yourwebsite.com/newsletter/subscribed.html'.");
+ throw new Exception(Piwik_TranslateException('Goals_ExceptionInvalidMatchingString', array("http:// or https://", "http://www.yourwebsite.com/newsletter/subscribed.html")));
}
}
@@ -121,12 +120,12 @@ class Piwik_Goals_API
public function deleteGoal( $idSite, $idGoal )
{
Piwik::checkUserHasAdminAccess($idSite);
- Piwik_Query("UPDATE ".Piwik::prefixTable('goal')."
+ Piwik_Query("UPDATE ".Piwik_Common::prefixTable('goal')."
SET deleted = 1
WHERE idsite = ?
AND idgoal = ?",
array($idSite, $idGoal));
- Piwik_Query("DELETE FROM ".Piwik::prefixTable("log_conversion")." WHERE idgoal = ?", $idGoal);
+ Piwik_Query("DELETE FROM ".Piwik_Common::prefixTable("log_conversion")." WHERE idgoal = ?", $idGoal);
Piwik_Common::regenerateCacheWebsiteAttributes($idSite);
}
@@ -157,7 +156,7 @@ class Piwik_Goals_API
$request = new Piwik_API_Request("method=VisitFrequency.getVisitsReturning&idSite=$idSite&period=$period&date=$date&format=original");
$nbVisitsReturning = $request->process();
// echo $nbVisitsConvertedReturningVisitors;
-// echo "<br>". $nbVisitsReturning;exit;
+// echo "<br />". $nbVisitsReturning;exit;
return Piwik::getPercentageSafe($nbVisitsConvertedReturningVisitors, $nbVisitsReturning, Piwik_Goals::ROUNDING_PRECISION);
}
@@ -211,7 +210,7 @@ class Piwik_Goals_API
return $dataTable;
}
- protected static function getNumeric( $idSite, $period, $date, $toFetch )
+ protected function getNumeric( $idSite, $period, $date, $toFetch )
{
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
@@ -221,16 +220,16 @@ class Piwik_Goals_API
public function getConversions( $idSite, $period, $date, $idGoal = false )
{
- return self::getNumeric( $idSite, $period, $date, Piwik_Goals::getRecordName('nb_conversions', $idGoal));
+ return $this->getNumeric( $idSite, $period, $date, Piwik_Goals::getRecordName('nb_conversions', $idGoal));
}
public function getConversionRate( $idSite, $period, $date, $idGoal = false )
{
- return self::getNumeric( $idSite, $period, $date, Piwik_Goals::getRecordName('conversion_rate', $idGoal));
+ return $this->getNumeric( $idSite, $period, $date, Piwik_Goals::getRecordName('conversion_rate', $idGoal));
}
public function getRevenue( $idSite, $period, $date, $idGoal = false )
{
- return self::getNumeric( $idSite, $period, $date, Piwik_Goals::getRecordName('revenue', $idGoal));
+ return $this->getNumeric( $idSite, $period, $date, Piwik_Goals::getRecordName('revenue', $idGoal));
}
}
diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php
index 06d16b93b0..04c54565ab 100644
--- a/plugins/Goals/Controller.php
+++ b/plugins/Goals/Controller.php
@@ -18,33 +18,54 @@ class Piwik_Goals_Controller extends Piwik_Controller
{
const CONVERSION_RATE_PRECISION = 1;
- function __construct()
+ protected $goalColumnNameToLabel = array(
+ 'nb_conversions' => 'Goals_ColumnConversions',
+ 'conversion_rate'=> 'Goals_ColumnConversionRate',
+ 'revenue' => 'Goals_ColumnRevenue',
+ );
+
+ public function __construct()
{
parent::__construct();
$this->idSite = Piwik_Common::getRequestVar('idSite');
- $this->goals = Piwik_Goals_API::getGoals($this->idSite);
+ $this->goals = Piwik_Goals_API::getInstance()->getGoals($this->idSite);
}
- function goalReport()
+ public function widgetGoalReport()
+ {
+ $view = $this->getGoalReportView();
+ $view->displayFullReport = false;
+ echo $view->render();
+ }
+
+ public function goalReport()
+ {
+ $view = $this->getGoalReportView();
+ $view->displayFullReport = true;
+ $view->goalSegments = $this->getAvailableGoalSegments();
+ echo $view->render();
+ }
+
+ protected function getGoalReportView()
{
$idGoal = Piwik_Common::getRequestVar('idGoal', null, 'int');
if(!isset($this->goals[$idGoal]))
{
- throw new Exception("idgoal $idGoal not valid.");
+ Piwik::redirectToModule('Goals', 'index', array('idGoal' => null));
}
$goalDefinition = $this->goals[$idGoal];
$view = Piwik_View::factory('single_goal');
- $view->currency = Piwik::getCurrency();
+ $this->setGeneralVariablesView($view);
$goal = $this->getMetricsForGoal($idGoal);
foreach($goal as $name => $value)
{
$view->$name = $value;
}
- $view->name = $goalDefinition['name'];
- $view->title = $goalDefinition['name'] . ' - Conversions';
+ $view->idGoal = $idGoal;
+ $view->goalName = $goalDefinition['name'];
$view->graphEvolution = $this->getEvolutionGraph(true, array(Piwik_Goals::getRecordName('nb_conversions', $idGoal)), $idGoal);
- $view->nameGraphEvolution = 'GoalsgetEvolutionGraph';
+ $view->nameGraphEvolution = 'GoalsgetEvolutionGraph'.$idGoal;
$view->topSegments = $this->getTopSegments($idGoal);
// conversion rate for new and returning visitors
@@ -52,75 +73,31 @@ class Piwik_Goals_Controller extends Piwik_Controller
$view->conversion_rate_returning = round( $request->process(), self::CONVERSION_RATE_PRECISION );
$request = new Piwik_API_Request("method=Goals.getConversionRateNewVisitors&format=original");
$view->conversion_rate_new = round( $request->process(), self::CONVERSION_RATE_PRECISION );
-
- $verticalSlider = array();
- // string label
- // array parameters to ajax call on click (module, action)
- // specific order
- // (intermediate labels)
- // automatically load the first from the list, highlights it
- $view->tableByConversion = Piwik_FrontController::getInstance()->fetchDispatch('Referers', 'getKeywords', array(false, 'tableGoals'));
- echo $view->render();
+ return $view;
}
- protected function getTopSegments($idGoal)
+ public function index()
{
- $columnNbConversions = 'goal_'.$idGoal.'_nb_conversions';
- $columnConversionRate = 'goal_'.$idGoal.'_conversion_rate';
-
- $topSegmentsToLoad = array(
- 'country' => 'UserCountry.getCountry',
- 'keyword' => 'Referers.getKeywords',
- 'website' => 'Referers.getWebsites',
- );
-
- $topSegments = array();
- foreach($topSegmentsToLoad as $segmentName => $apiMethod)
- {
- $request = new Piwik_API_Request("method=$apiMethod
- &format=original
- &filter_update_columns_when_show_all_goals=1
- &filter_sort_order=desc
- &filter_sort_column=$columnNbConversions
- &filter_limit=3");
- $datatable = $request->process();
- $topSegment = array();
- foreach($datatable->getRows() as $row)
- {
- $topSegment[] = array (
- 'name' => $row->getColumn('label'),
- 'nb_conversions' => $row->getColumn($columnNbConversions),
- 'conversion_rate' => $row->getColumn($columnConversionRate),
- 'metadata' => $row->getMetadata(),
- );
- }
- $topSegments[$segmentName] = $topSegment;
- }
- return $topSegments;
+ $view = $this->getOverviewView();
+ $view->goalsJSON = json_encode($this->goals);
+ $view->goalSegments = $this->getAvailableGoalSegments();
+ $view->userCanEditGoals = Piwik::isUserHasAdminAccess($this->idSite);
+ $view->displayFullReport = true;
+ echo $view->render();
}
- protected function getMetricsForGoal($idGoal)
+ public function widgetGoalsOverview( )
{
- $request = new Piwik_API_Request("method=Goals.get&format=original&idGoal=$idGoal");
- $datatable = $request->process();
- $dataRow = $datatable->getFirstRow();
- return array (
- 'id' => $idGoal,
- 'nb_conversions' => $dataRow->getColumn(Piwik_Goals::getRecordName('nb_conversions', $idGoal)),
- 'conversion_rate' => round($dataRow->getColumn(Piwik_Goals::getRecordName('conversion_rate', $idGoal)), 1),
- 'revenue' => $dataRow->getColumn(Piwik_Goals::getRecordName('revenue', $idGoal)),
- 'urlSparklineConversions' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('nb_conversions', $idGoal)), 'idGoal' => $idGoal)),
- 'urlSparklineConversionRate' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('conversion_rate', $idGoal)), 'idGoal' => $idGoal)),
- 'urlSparklineRevenue' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('revenue', $idGoal)), 'idGoal' => $idGoal)),
- );
+ $view = $this->getOverviewView();
+ $view->displayFullReport = false;
+ echo $view->render();
}
- function index()
+ protected function getOverviewView()
{
$view = Piwik_View::factory('overview');
- $view->currency = Piwik::getCurrency();
+ $this->setGeneralVariablesView($view);
- $view->title = 'All goals - evolution';
$view->graphEvolution = $this->getEvolutionGraph(true, array(Piwik_Goals::getRecordName('nb_conversions')));
$view->nameGraphEvolution = 'GoalsgetEvolutionGraph';
@@ -129,7 +106,7 @@ class Piwik_Goals_Controller extends Piwik_Controller
$view->urlSparklineConversionRate = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('conversion_rate'))));
$view->urlSparklineRevenue = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('revenue'))));
- $request = new Piwik_API_Request("method=Goals.get&format=original");
+ $request = new Piwik_API_Request("method=Goals.get&format=original&idGoal=0");
$datatable = $request->process();
$dataRow = $datatable->getFirstRow();
$view->nb_conversions = $dataRow->getColumn('Goal_nb_conversions');
@@ -145,26 +122,36 @@ class Piwik_Goals_Controller extends Piwik_Controller
$view->goalMetrics = $goalMetrics;
$view->goals = $this->goals;
- $view->goalsJSON = json_encode($this->goals);
- $view->userCanEditGoals = Piwik::isUserHasAdminAccess($this->idSite);
- echo $view->render();
+ return $view;
+ }
+
+ public function getLastNbConversionsGraph( $fetch = false )
+ {
+ $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Goals.getConversions');
+ return $this->renderView($view, $fetch);
}
- function addNewGoal()
+ public function getLastConversionRateGraph( $fetch = false )
+ {
+ $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Goals.getConversionRate');
+ return $this->renderView($view, $fetch);
+ }
+
+ public function getLastRevenueGraph( $fetch = false )
+ {
+ $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Goals.getRevenue');
+ return $this->renderView($view, $fetch);
+ }
+
+ public function addNewGoal()
{
$view = Piwik_View::factory('add_new_goal');
+ $this->setGeneralVariablesView($view);
$view->userCanEditGoals = Piwik::isUserHasAdminAccess($this->idSite);
- $view->currency = Piwik::getCurrency();
$view->onlyShowAddNewGoal = true;
echo $view->render();
}
- protected $goalColumnNameToLabel = array(
- 'nb_conversions' => 'Goals_ColumnConversions',
- 'conversion_rate'=> 'Goals_ColumnConversionRate',
- 'revenue' => 'Goals_ColumnRevenue',
- );
-
public function getEvolutionGraph( $fetch = false, $columns = false, $idGoal = false)
{
if(empty($columns))
@@ -193,7 +180,7 @@ class Piwik_Goals_Controller extends Piwik_Controller
if(!empty($idGoal) && isset($this->goals[$idGoal]))
{
$goalName = $this->goals[$idGoal]['name'];
- $columnTranslation = "$columnTranslation (goal \"$goalName\")";
+ $columnTranslation = "$columnTranslation (".Piwik_Translate('Goals_GoalX', "$goalName").")";
}
$view->setColumnTranslation($columnName, $columnTranslation);
}
@@ -201,21 +188,74 @@ class Piwik_Goals_Controller extends Piwik_Controller
return $this->renderView($view, $fetch);
}
- function getLastNbConversionsGraph( $fetch = false )
+ protected function getAvailableGoalSegments()
{
- $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Goals.getConversions');
- return $this->renderView($view, $fetch);
+ $segments = array();
+ Piwik_PostEvent('Goals.getAvailableGoalSegments', $segments);
+ $segmentsByGroup = array();
+ foreach($segments as $segment)
+ {
+ $group = $segment['group'];
+ unset($segment['group']);
+ $segmentsByGroup[$group][] = $segment;
+ }
+ return $segmentsByGroup;
}
- function getLastConversionRateGraph( $fetch = false )
+ protected function getTopSegments($idGoal)
{
- $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Goals.getConversionRate');
- return $this->renderView($view, $fetch);
+ $columnNbConversions = 'goal_'.$idGoal.'_nb_conversions';
+ $columnConversionRate = 'goal_'.$idGoal.'_conversion_rate';
+
+ $topSegmentsToLoad = array(
+ 'country' => 'UserCountry.getCountry',
+ 'keyword' => 'Referers.getKeywords',
+ 'website' => 'Referers.getWebsites',
+ );
+
+ $topSegments = array();
+ foreach($topSegmentsToLoad as $segmentName => $apiMethod)
+ {
+ $request = new Piwik_API_Request("method=$apiMethod
+ &format=original
+ &filter_update_columns_when_show_all_goals=1
+ &filter_only_display_idgoal=". Piwik_DataTable_Filter_UpdateColumnsWhenShowAllGoals::GOALS_FULL_TABLE ."
+ &filter_sort_order=desc
+ &filter_sort_column=$columnNbConversions
+ &filter_limit=3");
+ $datatable = $request->process();
+ $topSegment = array();
+ foreach($datatable->getRows() as $row)
+ {
+ $conversions = $row->getColumn($columnNbConversions);
+ if($conversions > 0)
+ {
+ $topSegment[] = array (
+ 'name' => $row->getColumn('label'),
+ 'nb_conversions' => $conversions,
+ 'conversion_rate' => $row->getColumn($columnConversionRate),
+ 'metadata' => $row->getMetadata(),
+ );
+ }
+ }
+ $topSegments[$segmentName] = $topSegment;
+ }
+ return $topSegments;
}
-
- function getLastRevenueGraph( $fetch = false )
+
+ protected function getMetricsForGoal($idGoal)
{
- $view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Goals.getRevenue');
- return $this->renderView($view, $fetch);
+ $request = new Piwik_API_Request("method=Goals.get&format=original&idGoal=$idGoal");
+ $datatable = $request->process();
+ $dataRow = $datatable->getFirstRow();
+ return array (
+ 'id' => $idGoal,
+ 'nb_conversions' => $dataRow->getColumn(Piwik_Goals::getRecordName('nb_conversions', $idGoal)),
+ 'conversion_rate' => round($dataRow->getColumn(Piwik_Goals::getRecordName('conversion_rate', $idGoal)), 1),
+ 'revenue' => $dataRow->getColumn(Piwik_Goals::getRecordName('revenue', $idGoal)),
+ 'urlSparklineConversions' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('nb_conversions', $idGoal)), 'idGoal' => $idGoal)),
+ 'urlSparklineConversionRate' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('conversion_rate', $idGoal)), 'idGoal' => $idGoal)),
+ 'urlSparklineRevenue' => $this->getUrlSparkline('getEvolutionGraph', array('columns' => array(Piwik_Goals::getRecordName('revenue', $idGoal)), 'idGoal' => $idGoal)),
+ );
}
}
diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php
index 7e36b3a4d3..6ab468f09e 100644
--- a/plugins/Goals/Goals.php
+++ b/plugins/Goals/Goals.php
@@ -26,11 +26,10 @@ class Piwik_Goals extends Piwik_Plugin
public function getInformation()
{
$info = array(
- 'name' => '(ALPHA) Goal Tracking',
- 'description' => 'Create Goals and see reports about your goal conversions: evolution over time, revenue per visit, conversions per referer, per keyword, etc.',
+ 'description' => Piwik_Translate('Goals_PluginDescription'),
'author' => 'Piwik',
- 'homepage' => 'http://piwik.org/',
- 'version' => '0.1',
+ 'author_homepage' => 'http://piwik.org/',
+ 'version' => Piwik_Version::VERSION,
'TrackerPlugin' => true, // this plugin must be loaded during the stats logging
);
@@ -55,11 +54,20 @@ class Piwik_Goals extends Piwik_Plugin
// add the 'goal' entry in the website array
$array =& $notification->getNotificationObject();
- $array['goals'] = Piwik_Goals_API::getGoals($idsite);
+ $array['goals'] = Piwik_Goals_API::getInstance()->getGoals($idsite);
}
function addWidgets()
{
+ Piwik_AddWidget('Goals_Goals', 'Goals_GoalsOverview', 'Goals', 'widgetGoalsOverview');
+ $goals = Piwik_Tracker_GoalManager::getGoalDefinitions(Piwik_Common::getRequestVar('idSite'));
+ if(count($goals) > 0)
+ {
+ foreach($goals as $goal)
+ {
+ Piwik_AddWidget('Goals_Goals', $goal['name'], 'Goals', 'widgetGoalReport', array('idGoal' => $goal['idgoal']));
+ }
+ }
}
function addMenus()
@@ -67,14 +75,14 @@ class Piwik_Goals extends Piwik_Plugin
$goals = Piwik_Tracker_GoalManager::getGoalDefinitions(Piwik_Common::getRequestVar('idSite'));
if(count($goals)==0)
{
- Piwik_AddMenu('Goals', 'Add a new Goal', array('module' => 'Goals', 'action' => 'addNewGoal'));
+ Piwik_AddMenu('Goals_Goals', 'Goals_AddNewGoal', array('module' => 'Goals', 'action' => 'addNewGoal'));
}
else
{
- Piwik_AddMenu('Goals', 'Overview', array('module' => 'Goals'));
+ Piwik_AddMenu('Goals_Goals', 'Goals_Overview', array('module' => 'Goals', 'action' => 'index'));
foreach($goals as $goal)
{
- Piwik_AddMenu('Goals', str_replace('%', '%%', $goal['name']), array('module' => 'Goals', 'action' => 'goalReport', 'idGoal' => $goal['idgoal']));
+ Piwik_AddMenu('Goals_Goals', str_replace('%', '%%', $goal['name']), array('module' => 'Goals', 'action' => 'goalReport', 'idGoal' => $goal['idgoal']));
}
}
}
@@ -88,7 +96,7 @@ class Piwik_Goals extends Piwik_Plugin
static public function getRecordName($recordName, $idGoal = false, $visitorReturning = false)
{
$idGoalStr = $returningStr = '';
- if($idGoal !== false)
+ if(!empty($idGoal))
{
$idGoalStr = $idGoal . "_";
}
@@ -180,14 +188,14 @@ class Piwik_Goals extends Piwik_Plugin
$metricName = Piwik_Archive::$mappingFromIdToNameGoal[$metricId];
$recordName = self::getRecordName($metricName, $idgoal, $visitor_returning);
$archiveProcessing->insertNumericRecord($recordName, $value);
-// echo $record . "<br>";
+// echo $record . "<br />";
}
}
}
// Stats for all goals
$totalAllGoals = array(
- self::getRecordName('conversion_rate') => round(100 * $archiveProcessing->getNumberOfVisitsConverted() / $archiveProcessing->getNumberOfVisits(), self::ROUNDING_PRECISION),
+ self::getRecordName('conversion_rate') => $this->getConversionRate($archiveProcessing->getNumberOfVisitsConverted(), $archiveProcessing),
self::getRecordName('nb_conversions') => $nb_conversions,
self::getRecordName('revenue') => $revenue,
);
diff --git a/plugins/Goals/templates/GoalForm.js b/plugins/Goals/templates/GoalForm.js
index f3c5af4227..13ed40ba5e 100644
--- a/plugins/Goals/templates/GoalForm.js
+++ b/plugins/Goals/templates/GoalForm.js
@@ -1,20 +1,37 @@
function showAddNewGoal()
{
+ hideForms();
$("#GoalForm").show();
- $("#EditGoals").hide();
- $.scrollTo("#AddEditGoals", 400);
+ showCancel();
+ piwikHelper.lazyScrollTo("#AddEditGoals", 400);
return false;
}
function showEditGoals()
{
+ hideForms();
$("#EditGoals").show();
- $("#GoalForm").hide();
- $.scrollTo("#AddEditGoals", 400);
+ showCancel();
+ piwikHelper.lazyScrollTo("#AddEditGoals", 400);
return false;
}
+function hideForms()
+{
+ $("#GoalForm").hide();
+ $("#EditGoals").hide();
+}
+
+function showCancel()
+{
+ $("#goalsCancel").show();
+ $('#goalsCancelLink').click( function(){
+ hideForms();
+ $("#goalsCancel").hide();
+ });
+}
+
// init the goal form with existing goal value, if any
function initGoalForm(goalMethodAPI, submitText, goalName, matchAttribute, pattern, patternType, caseSensitive, revenue, goalId)
{
@@ -42,11 +59,6 @@ function initGoalForm(goalMethodAPI, submitText, goalName, matchAttribute, patte
}
}
-function initAndShowAddGoalForm()
-{
- initGoalForm('Goals.addGoal', 'Add Goal', '', 'url', '', 'contains', false, '0');
- return showAddNewGoal();
-}
function bindGoalForm()
{
@@ -78,78 +90,85 @@ function bindGoalForm()
$('a[name=linkAddNewGoal]').click( function(){
initAndShowAddGoalForm();
+ piwikHelper.lazyScrollTo('#goal_name');
} );
}
-function bindListGoalEdit()
-{
- $('a[name=linkEditGoal]').click( function() {
- var goalId = $(this).attr('id');
- var goal = piwik.goals[goalId];
- initGoalForm("Goals.updateGoal", "Update Goal", goal.name, goal.match_attribute, goal.pattern, goal.pattern_type, (goal.case_sensitive=='0' ? false : true), goal.revenue, goalId);
- showAddNewGoal();
- return false;
- });
-
- $('a[name=linkDeleteGoal]').click( function() {
- var goalId = $(this).attr('id');
- var goal = piwik.goals[goalId];
- if(confirm(sprintf("Are you sure you want to delete the Goal '%s'?", goal.name)))
- {
- $.ajax( getAjaxDeleteGoal( goalId ) );
- }
- return false;
- });
-
- $('a[name=linkEditGoals]').click( function(){
- return showEditGoals();
- } );
-}
function getAjaxDeleteGoal(idGoal)
{
- var ajaxRequest = piwikHelper.getStandardAjaxConf();
- piwikHelper.toggleAjaxLoading();
+ var ajaxRequest = piwikHelper.getStandardAjaxConf('goalAjaxLoading');
+ piwikHelper.lazyScrollTo("#AddEditGoals", 400);
var parameters = {};
parameters.idSite = piwik.idSite;
- parameters.idGoal = idGoal;
- parameters.method = 'Goals.deleteGoal';
+ parameters.idGoal = idGoal;
+ parameters.method = 'Goals.deleteGoal';
parameters.module = 'API';
parameters.format = 'json';
- parameters.token_auth = piwik.token_auth;
+ parameters.token_auth = piwik.token_auth;
ajaxRequest.data = parameters;
return ajaxRequest;
}
function getAjaxAddGoal()
{
- var ajaxRequest = piwikHelper.getStandardAjaxConf();
- piwikHelper.toggleAjaxLoading();
-
+ var ajaxRequest = piwikHelper.getStandardAjaxConf('goalAjaxLoading');
+ piwikHelper.lazyScrollTo("#AddEditGoals", 400);
var parameters = {};
parameters.idSite = piwik.idSite;
parameters.name = encodeURIComponent( $('#goal_name').val() );
-
+
if($('[name=trigger_type]').val() == 'manually') {
parameters.matchAttribute = 'manually';
parameters.patternType = 'regex';
parameters.pattern = '.*';
parameters.caseSensitive = 0;
} else {
- parameters.matchAttribute = $('input[name=match_attribute][checked]').val();
+ parameters.matchAttribute = $('input[name=match_attribute]:checked').val();
parameters.patternType = $('[name=pattern_type]').val();
parameters.pattern = encodeURIComponent( $('input[name=pattern]').val() );
parameters.caseSensitive = $('#case_sensitive').attr('checked') == true ? 1: 0;
}
parameters.revenue = $('input[name=revenue]').val();
- parameters.idGoal = $('input[name=goalIdUpdate]').val();
- parameters.method = $('input[name=methodGoalAPI]').val();
+ parameters.idGoal = $('input[name=goalIdUpdate]').val();
+ parameters.method = $('input[name=methodGoalAPI]').val();
parameters.module = 'API';
parameters.format = 'json';
- parameters.token_auth = piwik.token_auth;
+ parameters.token_auth = piwik.token_auth;
ajaxRequest.data = parameters;
return ajaxRequest;
}
+
+function bindListGoalEdit()
+{
+ $('a[name=linkEditGoal]').click( function() {
+ var goalId = $(this).attr('id');
+ var goal = piwik.goals[goalId];
+ initGoalForm("Goals.updateGoal", _pk_translate('Goals_UpdateGoal_js'), goal.name, goal.match_attribute, goal.pattern, goal.pattern_type, (goal.case_sensitive=='0' ? false : true), goal.revenue, goalId);
+ showAddNewGoal();
+ return false;
+ });
+
+ $('a[name=linkDeleteGoal]').click( function() {
+ var goalId = $(this).attr('id');
+ var goal = piwik.goals[goalId];
+ if(confirm(sprintf(_pk_translate('Goals_DeleteGoalConfirm_js'), '"'+goal.name+'"')))
+ {
+ $.ajax( getAjaxDeleteGoal( goalId ) );
+ }
+ return false;
+ });
+
+ $('a[name=linkEditGoals]').click( function(){
+ return showEditGoals();
+ } );
+}
+
+function initAndShowAddGoalForm()
+{
+ initGoalForm('Goals.addGoal', _pk_translate('Goals_AddGoal_js'), '', 'url', '', 'contains', false, '0');
+ return showAddNewGoal();
+} \ No newline at end of file
diff --git a/plugins/Goals/templates/add_edit_goal.tpl b/plugins/Goals/templates/add_edit_goal.tpl
index c09f1cdab3..e78a8eb391 100644
--- a/plugins/Goals/templates/add_edit_goal.tpl
+++ b/plugins/Goals/templates/add_edit_goal.tpl
@@ -1,44 +1,54 @@
-
-<div id="AddEditGoals">
{if isset($onlyShowAddNewGoal)}
- <h2>Add a new Goal</h2>
+ <h2>{'Goals_AddNewGoal'|translate}</h2>
+ <p>{'Goals_DescriptionGoalsManagement'|translate} </p>
+ <p>{'Goals_LearnMoreAboutGoalTrackingDocumentation'|translate:"<a href='misc/redirectToUrl.php?url=http://piwik.org/docs/tracking-goals-web-analytics/' target='_blank'>":"</a>"}
+ </p>
{else}
- <h2><a onclick='' name="linkAddNewGoal">+ Add a new Goal</a>
- or <a onclick='' name="linkEditGoals">Edit</a> existing Goals</h2>
+ <h2>{'Goals_GoalsManagement'|translate}</h2>
+ <ul class='listCircle'>
+ <li><a onclick='' name='linkAddNewGoal'><u>{'Goals_CreateNewGOal'|translate}</u></a></li>
+ <li><a onclick='' name='linkEditGoals'>{'Goals_ViewAndEditGoals'|translate}</a></li>
+ <li>{'Goals_LearnMoreAboutGoalTrackingDocumentation'|translate:"<a href='misc/redirectToUrl.php?url=http://piwik.org/docs/tracking-goals-web-analytics/' target='_blank'>":"</a>"}</li>
+ </ul>
+ <br/>
{/if}
- <div>
- <div id="ajaxError" style="display:none"></div>
- <div id="ajaxLoading" style="display:none"><div id="loadingPiwik"><img src="themes/default/images/loading-blue.gif" alt="" /> {'General_LoadingData'|translate}</div></div>
- </div>
+{ajaxErrorDiv}
+{ajaxLoadingDiv id=goalAjaxLoading}
-{if !isset($onlyShowAddNewGoal)}
- {include file="Goals/templates/list_goal_edit.tpl"}
-{/if}
+<div id="AddEditGoals">
+ {if !isset($onlyShowAddNewGoal)}
+ {include file="Goals/templates/list_goal_edit.tpl"}
+ {/if}
{include file="Goals/templates/form_add_goal.tpl"}
-
+ {if !isset($onlyShowAddNewGoal)}
+ <div id='goalsCancel'>{'General_OrCancel'|translate:"<a id='goalsCancelLink'>":"</a>"}</div>
+ {/if}
<a id='bottom'></a>
</div>
-{literal}
+{loadJavascriptTranslations plugins='Goals'}
<script type="text/javascript" src="plugins/Goals/templates/GoalForm.js"></script>
-<script language="javascript">
-
-var mappingMatchTypeName = {
- "url": "URL",
- "file": "filename",
- "external_website": "external website URL"
-};
-var mappingMatchTypeExamples = {
- "url": "eg. contains 'checkout/confirmation'<br>eg. is exactly 'http://example.com/thank-you.html'<br>eg. matches the expression '(.*)\\\/demo\\\/(.*)'",
- "file": "eg. contains 'files/brochure.pdf'<br>eg. is exactly 'http://example.com/files/brochure.pdf'<br>eg. matches the expression '(.*)\\\.zip'",
- "external_website": "eg. contains 'amazon.com'<br>eg. is exactly 'http://mypartner.com/landing.html'<br>eg. matches the expression 'http://www.amazon.com\\\/(.*)\\\/yourAffiliateId'"
-};
-
+<script type="text/javascript">
+
+var mappingMatchTypeName = {ldelim}
+ "url": "{'Goals_URL'|translate|escape}",
+ "file": "{'Goals_Filename'|translate|escape}",
+ "external_website": "{'Goals_ExternalWebsiteUrl'|translate|escape}"
+{rdelim};
+var mappingMatchTypeExamples = {ldelim}
+ "url": "{'General_ForExampleShort'|translate} {'Goals_Contains'|translate:"'checkout/confirmation'"|escape} \
+ <br />{'General_ForExampleShort'|translate|escape} {'Goals_IsExactly'|translate:"'http://example.com/thank-you.html'"|escape} \
+ <br />{'General_ForExampleShort'|translate|escape} {'Goals_MatchesExpression'|translate:"'(.*)\\\/demo\\\/(.*)'"|escape}",
+ "file": "{'General_ForExampleShort'|translate|escape} {'Goals_Contains'|translate:"'files/brochure.pdf'"|escape} \
+ <br />{'General_ForExampleShort'|translate|escape} {'Goals_IsExactly'|translate:"'http://example.com/files/brochure.pdf'"|escape} \
+ <br />{'General_ForExampleShort'|translate|escape} {'Goals_MatchesExpression'|translate:"'(.*)\\\.zip'"|escape}",
+ "external_website": "{'General_ForExampleShort'|translate|escape} {'Goals_Contains'|translate:"'amazon.com'"|escape} \
+ <br />{'General_ForExampleShort'|translate|escape} {'Goals_IsExactly'|translate:"'http://mypartner.com/landing.html'"|escape} \
+ <br />{'General_ForExampleShort'|translate|escape} {'Goals_MatchesExpression'|translate:"'http://www.amazon.com\\\/(.*)\\\/yourAffiliateId'"|escape}"
+{rdelim};
bindGoalForm();
-{/literal}
-
{if !isset($onlyShowAddNewGoal)}
piwik.goals = {$goalsJSON};
bindListGoalEdit();
diff --git a/plugins/Goals/templates/add_new_goal.tpl b/plugins/Goals/templates/add_new_goal.tpl
index 05a7f66e8d..7450bf4764 100644
--- a/plugins/Goals/templates/add_new_goal.tpl
+++ b/plugins/Goals/templates/add_new_goal.tpl
@@ -2,7 +2,5 @@
{if $userCanEditGoals}
{include file=Goals/templates/add_edit_goal.tpl}
{else}
-Only an Administrator or the Super User can add Goals for a given website.
-Please ask your Piwik administrator to set up a Goal for your website.
-<br>Tracking Goals are a great tool to help you maximize your website performance!
+{'Goals_NoGoalsNeedAccess'|translate}
{/if}
diff --git a/plugins/Goals/templates/form_add_goal.tpl b/plugins/Goals/templates/form_add_goal.tpl
index b60dbe7ad4..76350d9f40 100644
--- a/plugins/Goals/templates/form_add_goal.tpl
+++ b/plugins/Goals/templates/form_add_goal.tpl
@@ -1,85 +1,74 @@
-{literal}
-<style>
-.goalInlineHelp{
-color:#9B9B9B;
-}
-</style>
-{/literal}
<span id='GoalForm' style="display:none;">
<form>
- <table class="tableForm">
- <tbody>
- <tr>
- <td>Goal Name </td>
- <td><input type="text" name="name" value="" id="goal_name" /></td>
+<table class="tableForm tableFormGoals">
+ <tbody>
+ <tr>
+ <td>{'Goals_GoalName'|translate} </td>
+ <td><input type="text" name="name" value="" id="goal_name" /></td>
+ </tr>
+ <tr>
+ <td style='width:240px;'>{'Goals_GoalIsTriggered'|translate}
+ <select name="trigger_type">
+ <option value="visitors">{'Goals_WhenVisitors'|translate}</option>
+ <option value="manually">{'Goals_Manually'|translate}</option>
+ </select>
+ </td>
+ <td>
+ <input type="radio" id="match_attribute_url" value="url" name="match_attribute" />
+ <label for="match_attribute_url">{'Goals_VisitUrl'|translate}</label>
+ <br />
+ <input type="radio" id="match_attribute_file" value="file" name="match_attribute" />
+ <label for="match_attribute_file">{'Goals_Download'|translate}</label>
+ <br />
+ <input type="radio" id="match_attribute_external_website" value="external_website" name="match_attribute" />
+ <label for="match_attribute_external_website">{'Goals_ClickOutlink'|translate}</label>
+ </td>
</tr>
- <tr>
- <td>Goal is triggered
- <select name="trigger_type">
- <option value="visitors">when visitors</option>
- <option value="manually">manually</option>
- </select>
- </td>
- <td>
- <input type="radio" id="match_attribute_url" value="url" name="match_attribute"/>
- <label for="match_attribute_url">Visit a given URL (page or group of pages)</label>
- <br />
- <input type="radio" id="match_attribute_file" value="file" name="match_attribute"/>
- <label for="match_attribute_file">Download a file</label>
- <br />
- <input type="radio" id="match_attribute_external_website" value="external_website" name="match_attribute"/>
- <label for="match_attribute_external_website">Click on a Link to an external website </label>
- </td>
- </tr>
- </tbody>
- <tbody id="match_attribute_section">
- <tr>
- <td>where the <span id="match_attribute_name"></span></td>
- <td>
- <select name="pattern_type">
- <option value="contains">contains</option>
- <option value="exact">is exactly</option>
- <option value="regex">matches the expression</option>
- </select>
-
- <input type="text" name="pattern" value=""/>
- <br />
- <div id="examples_pattern" class="goalInlineHelp"></div>
- <br />
- <span style="float:right">
- (optional) <input type="checkbox" id="case_sensitive"/>
- <label for="case_sensitive">Case sensitive match</label>
- </span>
- </td>
- </tr>
- </tbody>
- <tbody id="manual_trigger_section" style="display:none">
- <tr>
- <td colspan="2">
- where the visited page manually calls the JavaScript piwikTracker.trackGoal() method (<a target='_blank' href='misc/redirectToUrl.php?url=http://piwik.org/docs/javascript-tracking/'>learn more</a>)
- </td>
- </tr>
- </tbody>
- <tbody>
- <tr>
- <td>(optional) Goal default value is </td>
- <td>{$currency} <input type="text" name="revenue" size="1" value="0"/>
- <div class="goalInlineHelp">
- For example, a Contact Form submitted by a visitor <br />
- may be worth $10 on average. Piwik will help you understand <br />
- how well your visitors segments are performing.</div>
- </td>
- </tr>
- <tr>
- <td colspan="2" style="border:0">
- <div class="submit">
- <input type="hidden" name="methodGoalAPI" value="">
- <input type="hidden" name="goalIdUpdate" value="">
- <input type="submit" value="Add Goal" name="submit" id="goal_submit" class="submit" />
- </div>
- </td>
- </tr>
- </tbody>
- </table>
+ </tbody>
+ <tbody id="match_attribute_section">
+ <tr>
+ <td>{'Goals_WhereThe'|translate} <span id="match_attribute_name"></span></td>
+ <td>
+ <select name="pattern_type">
+ <option value="contains">{'Goals_Contains'|translate:""}</option>
+ <option value="exact">{'Goals_IsExactly'|translate:""}</option>
+ <option value="regex">{'Goals_MatchesExpression'|translate:""}</option>
+ </select>
+
+ <input type="text" name="pattern" value="" />
+ <br />
+ <div id="examples_pattern" class="goalInlineHelp"></div>
+ <br />
+ <span style="float:right">
+ {'Goals_Optional'|translate} <input type="checkbox" id="case_sensitive" />
+ <label for="case_sensitive">{'Goals_CaseSensitive'|translate}</label>
+ </span>
+ </td>
+ </tr>
+ </tbody>
+ <tbody id="manual_trigger_section" style="display:none">
+ <tr><td colspan="2">
+ {'Goals_WhereVisitedPageManuallyCallsJavascriptTrackerLearnMore'|translate:"<a target='_blank' href='misc/redirectToUrl.php?url=http://piwik.org/docs/javascript-tracking/'>":"</a>"}
+ </td></tr>
+ </tbody>
+ <tbody>
+ <tr>
+ <td>(optional) {'Goals_DefaultRevenue'|translate}</td>
+ <td>{'<input type="text" name="revenue" size="1" value="0" />'|money:$idSite}
+ <div class="goalInlineHelp"> {'Goals_DefaultRevenueHelp'|translate} </div>
+ </td>
+ </tr>
+ <tr>
+ <tr>
+ <td colspan="2" style="border:0">
+ <input type="hidden" name="methodGoalAPI" value="" />
+ <input type="hidden" name="goalIdUpdate" value="" />
+ <center>
+ <input type="submit" value="" name="submit" id="goal_submit" class="submit" />
+ </center>
+ </td>
+ </tr>
+ </tbody>
+</table>
</form>
</span>
diff --git a/plugins/Goals/templates/goals.css b/plugins/Goals/templates/goals.css
new file mode 100644
index 0000000000..2fc9e0fbd5
--- /dev/null
+++ b/plugins/Goals/templates/goals.css
@@ -0,0 +1,40 @@
+ul.ulGoalTopElements {
+ list-style-type:circle;
+ margin-left:30px;
+}
+.ulGoalTopElements a {
+ text-decoration:none;
+ color:#0033CC;
+ border-bottom:1px dotted #0033CC;
+ line-height:2em;
+}
+.goalTopElement {
+ border-bottom:1px dotted;
+}
+.listCircle {
+ list-style:circle outside none;
+ margin-left:30px;
+}
+.segmentSelector ul li .segment{
+ cursor:pointer;
+ border-bottom:1px dotted black;
+}
+.segmentSelector ul li.activeSegment .segment {
+ font-weight: bold;
+ border:0;
+}
+
+#titleGoalsBySegment {
+ padding-top:30px;
+}
+.goalInlineHelp {
+ color:#9B9B9B;
+}
+.tableFormGoals {
+ width:700px;
+}
+#goalsCancel {
+ margin-left:550px;
+ margin-top:20px;
+ display:none;
+} \ No newline at end of file
diff --git a/plugins/Goals/templates/list_goal_edit.tpl b/plugins/Goals/templates/list_goal_edit.tpl
index 92cab34b25..805f3c2277 100644
--- a/plugins/Goals/templates/list_goal_edit.tpl
+++ b/plugins/Goals/templates/list_goal_edit.tpl
@@ -1,22 +1,41 @@
<span id='EditGoals' style="display:none;">
- <table class="tableForm">
+ <table class="tableForm tableFormGoals">
<thead style="font-weight:bold">
<td>Id</td>
- <td>Goal Name</td>
- <td>Goal is Triggered when</td>
- <td>Revenue</td>
- <td>Edit</td>
- <td>Delete</td>
+ <td>{'Goals_GoalName'|translate}</td>
+ <td>{'Goals_GoalIsTriggeredWhen'|translate}</td>
+ <td>{'Goals_ColumnRevenue'|translate}</td>
+ <td>{'General_Edit'|translate}</td>
+ <td>{'General_Delete'|translate}</td>
</thead>
{foreach from=$goals item=goal}
<tr>
<td>{$goal.idgoal}</td>
<td>{$goal.name}</td>
- <td>{$goal.match_attribute} {if isset($goal.pattern_type)}<br>Pattern {$goal.pattern_type}: {$goal.pattern}</b>{/if}</td>
- <td>{if $goal.revenue==0}-{else}{$currency}{$goal.revenue}{/if}</td>
- <td><a href='#' name="linkEditGoal" id="{$goal.idgoal}"><img src='plugins/UsersManager/images/edit.png' border=0> Edit</a></td>
- <td><a href='#' name="linkDeleteGoal" id="{$goal.idgoal}"><img src='plugins/UsersManager/images/remove.png' border=0> Delete</a></td>
+ <td><span class='matchAttribute'>{$goal.match_attribute}</span> {if isset($goal.pattern_type)}<br />{'Goals_Pattern'|translate} {$goal.pattern_type}: {$goal.pattern}</b>{/if}</td>
+ <td>{if $goal.revenue==0}-{else}{$goal.revenue|money:$idSite}{/if}</td>
+ <td><a href='#' name="linkEditGoal" id="{$goal.idgoal}"><img src='plugins/UsersManager/images/edit.png' border="0" /> {'General_Edit'|translate}</a></td>
+ <td><a href='#' name="linkDeleteGoal" id="{$goal.idgoal}"><img src='plugins/UsersManager/images/remove.png' border="0" /> {'General_Delete'|translate}</a></td>
</tr>
{/foreach}
</table>
</span>
+
+<script type="text/javascript">
+var goalTypeToTranslation = {ldelim}
+ "manually" : "{'Goals_ManuallyTriggeredUsingJavascriptFunction'|translate}",
+ "file" : "{'Goals_Download'|translate}",
+ "url" : "{'Goals_VisitUrl'|translate}",
+ "external_website" : "{'Goals_ClickOutlink'|translate}"
+{rdelim}
+{literal}
+$(document).ready( function() {
+ // translation of the goal "match attribute" to human readable description
+ $('.matchAttribute').each( function() {
+ matchAttribute = $(this).text();
+ translation = goalTypeToTranslation[matchAttribute];
+ $(this).text(translation);
+ });
+} );
+{/literal}
+</script>
diff --git a/plugins/Goals/templates/list_top_segment.tpl b/plugins/Goals/templates/list_top_segment.tpl
index 6dbe69813f..4e1ca412d3 100644
--- a/plugins/Goals/templates/list_top_segment.tpl
+++ b/plugins/Goals/templates/list_top_segment.tpl
@@ -1,5 +1,10 @@
{foreach from=$topSegment item=element name=topGoalElements}
-<span class='goalTopElement' title='<b>{$element.nb_conversions}</b> conversions, <b>{$element.conversion_rate}%</b> conversion rate'>
-{$element.name}</span>{logoHtml metadata=$element.metadata alt=$element.name}{if $smarty.foreach.topGoalElements.iteration == $smarty.foreach.topGoalElements.total-1} and {elseif $smarty.foreach.topGoalElements.iteration < $smarty.foreach.topGoalElements.total-1}, {else}{/if}
-{/foreach} {* (<a href=''>more</a>) *}
+ {assign var=goal_nb_conversion value=$element.nb_conversions}
+ {assign var=goal_conversion_rate value=$element.conversion_rate}
+ <span class='goalTopElement' title='{'Goals_Conversions'|translate:"<b>$goal_nb_conversion</b>"},
+ {'Goals_ConversionRate'|translate:"<b>$goal_conversion_rate%</b>"}'>
+ {$element.name}</span>
+ {logoHtml metadata=$element.metadata alt=$element.name}
+ {if $smarty.foreach.topGoalElements.iteration == $smarty.foreach.topGoalElements.total-1} and {elseif $smarty.foreach.topGoalElements.iteration < $smarty.foreach.topGoalElements.total-1}, {else}{/if}
+{/foreach} \ No newline at end of file
diff --git a/plugins/Goals/templates/overview.tpl b/plugins/Goals/templates/overview.tpl
index 1e342840dc..f08633c487 100644
--- a/plugins/Goals/templates/overview.tpl
+++ b/plugins/Goals/templates/overview.tpl
@@ -1,23 +1,32 @@
+<link rel="stylesheet" type="text/css" href="plugins/Goals/templates/goals.css" />
{include file="Goals/templates/title_and_evolution_graph.tpl"}
{foreach from=$goalMetrics item=goal}
-{assign var=nb_conversions value=$goal.nb_conversions}
-{assign var=conversion_rate value=$goal.conversion_rate}
-<h2 style="padding-top: 30px;">{$goal.name} (goal)</h2>
-<div id='leftcolumn'>
- <div class="sparkline">{sparkline src=$goal.urlSparklineConversions}
- {'%s conversions'|translate:"<strong>$nb_conversions</strong>"}</div>
-</div>
-<div id='rightcolumn'>
- <div class="sparkline">{sparkline src=$goal.urlSparklineConversionRate}
- {'%s conversion rate'|translate:"<strong>$conversion_rate%</strong>"}</div>
- {* (<a href=''>more</a>) *}
-</div>
+ {assign var=nb_conversions value=$goal.nb_conversions}
+ {assign var=conversion_rate value=$goal.conversion_rate}
+ {assign var=name value=$goal.name}
+
+ <h2 style="padding-top: 30px;">
+ {if $displayFullReport}<a href="javascript:broadcast.propagateAjax('module=Goals&action=goalReport&idGoal={$goal.id}')">{/if}
+ {'Goals_GoalX'|translate:"'$name'"}
+ {if $displayFullReport}</a>{/if}
+ </h2>
+ <div id='leftcolumn'>
+ <div class="sparkline">{sparkline src=$goal.urlSparklineConversions}
+ {'Goals_Conversions'|translate:"<strong>$nb_conversions</strong>"}</div>
+ </div>
+ <div id='rightcolumn'>
+ <div class="sparkline">{sparkline src=$goal.urlSparklineConversionRate}
+ {'Goals_ConversionRate'|translate:"<strong>$conversion_rate%</strong>"}</div>
+ </div>
{/foreach}
-{if $userCanEditGoals}
- {include file=Goals/templates/add_edit_goal.tpl}
-{/if}
+{if $displayFullReport}
-{include file="Goals/templates/release_notes.tpl}
+ {include file="Goals/templates/table_by_segment.tpl"}
+
+ {if $userCanEditGoals}
+ {include file=Goals/templates/add_edit_goal.tpl}
+ {/if}
+{/if} \ No newline at end of file
diff --git a/plugins/Goals/templates/release_notes.tpl b/plugins/Goals/templates/release_notes.tpl
deleted file mode 100644
index d987a7d849..0000000000
--- a/plugins/Goals/templates/release_notes.tpl
+++ /dev/null
@@ -1,36 +0,0 @@
-<div style="clear:both" />
-<br><br><hr>
-<b>About the Goal Tracking Plugin</b><br>
-<pre>
-The Goal Tracking Plugin is in alpha release. There is more coming soon!
-
-Give us Feedback!
-If you find any other bug, or if you have suggestions, please send us a message using the "Give us feedback" link at the top of the Piwik pages.
-
-Work left to do on the Goal Tracking plugin:
-- The Goal Report page will display conversion table by search engines, country, keyword, campaign, etc.
-- Contemplate adding goal conversions per landing page? If we add Goals per landing page, what page is used for goals that are triggered using piwikTracker.trackGoal in javascript?
-- The Goal Overview page will link to a Goal Report page with a "(more)" link that will ajax reload the page
-- Provide widgets for the dashboard, general goal overview, and one widget for each goal. With: graph evolution, sparklines. Widget with top segments for each goal.
-- Add visits with conversion sparkline in VisitsSummary overview
-- Add link under goal conversion to full goal reports (optional display)
-- Internationalization of all strings i18n
-- Provide documentation, screenshots, blog post + add screenshot and inline help in "Add a New Goal"
-- N/A% should be n/a
-- Way to test a URL against the regex
-- Test summary row works ok with subtables campaigns
-
-Known bugs
-- see bug described in http://forum.piwik.org/index.php?showtopic=150
-- Your top converting keyword include keyword without conversions?
-- The Goal total nb conversions should be sum of all goal conversions (wrong number when deleting a Goal)
-- After adding goal, the window should ideally refresh to the goal report page, and not to the dashboard
-- Outlink trailing slash is automatically deleted from the URL, there would be a problem when trying to exact match a URL with trailing slash
-- lines with 0 visits and no conversion should not appear
-
-Feature requests
-- need to clarify that goals are triggered once per visit max, but can be triggered multiple times by one unique visitor > need option to force only once per uniq visitor? (ie. e-commerce transaction)
-- GeoIp compatibility, archive goals by city, country? see archiveDayAggregateGoals
-- Goal conversions, revenue, etc. by hour
-- I would like to be able to plot conversions, for a given keyword/website, over the last N days/weeks/etc. See #534
-- when entering the regex to detect as a goal, we could query the piwik API for this regex and list all URLs that match the regex; allows for an easy debug/check that the regex is correct and will be triggererd when expected
diff --git a/plugins/Goals/templates/single_goal.tpl b/plugins/Goals/templates/single_goal.tpl
index 289be7b417..41968df30e 100644
--- a/plugins/Goals/templates/single_goal.tpl
+++ b/plugins/Goals/templates/single_goal.tpl
@@ -1,40 +1,28 @@
+<link rel="stylesheet" type="text/css" href="plugins/Goals/templates/goals.css" />
{include file="Goals/templates/title_and_evolution_graph.tpl"}
-<div style="clear:both"></div>
+<div style="clear:both;"></div>
{if $nb_conversions > 0}
- <h2>Conversions Overview</h2>
+ <h2>{'Goals_ConversionsOverview'|translate}</h2>
<ul class="ulGoalTopElements">
- <li>Your best converting countries are: {include file='Goals/templates/list_top_segment.tpl' topSegment=$topSegments.country}</li>
- {if count($topSegments.keyword)>0}<li>Your top converting keywords are: {include file='Goals/templates/list_top_segment.tpl' topSegment=$topSegments.keyword}</li>{/if}
- {if count($topSegments.website)>0}<li>Your best converting websites referers are: {include file='Goals/templates/list_top_segment.tpl' topSegment=$topSegments.website}</li>{/if}
- <li>Returning visitors conversion rate is <b>{$conversion_rate_returning}%</b>, New Visitors conversion rate is <b>{$conversion_rate_new}%</b></li>
+ <li>{'Goals_BestCountries'|translate} {include file='Goals/templates/list_top_segment.tpl' topSegment=$topSegments.country}</li>
+ {if count($topSegments.keyword)>0}<li>{'Goals_BestKeywords'|translate} {include file='Goals/templates/list_top_segment.tpl' topSegment=$topSegments.keyword}</li>{/if}
+ {if count($topSegments.website)>0}<li>{'Goals_BestReferers'|translate} {include file='Goals/templates/list_top_segment.tpl' topSegment=$topSegments.website}</li>{/if}
+ <li>{'Goals_ReturningVisitorsConversionRateIs'|translate:"<b>$conversion_rate_returning%</b>"}, {'Goals_NewVisitorsConversionRateIs'|translate:"<b>$conversion_rate_new%</b>"}</li>
</ul>
{/if}
-<hr>
-{$tableByConversion}
-<hr>
+
{literal}
-<style>
-ul.ulGoalTopElements {
- list-style-type:circle;
- margin-left:30px;
-}
-.ulGoalTopElements a {
- text-decoration:none;
- color:#0033CC;
- border-bottom:1px dotted #0033CC;
- line-height:2em;
-}
-.goalTopElement {
- border-bottom:1px dotted;
-}
-</style>
-<script>
+<script type="text/javascript">
$(document).ready( function() {
- $('.goalTopElement')
- .tooltip()
- ;
- });
+ $('.goalTopElement').tooltip();
+});
</script>
{/literal}
+
+{if $displayFullReport}
+ {if $nb_conversions > 0}
+ {include file="Goals/templates/table_by_segment.tpl"}
+ {/if}
+{/if} \ No newline at end of file
diff --git a/plugins/Goals/templates/table_by_segment.tpl b/plugins/Goals/templates/table_by_segment.tpl
new file mode 100644
index 0000000000..3dfa45eaa5
--- /dev/null
+++ b/plugins/Goals/templates/table_by_segment.tpl
@@ -0,0 +1,72 @@
+<h2 id='titleGoalsBySegment'>{if isset($idGoal)}
+ {'Goals_GoalConversionsBySegment'|translate:$goalName}
+ {else}{'Goals_ConversionsOverviewBySegment'|translate}{/if}</h2>
+
+<div class='segmentSelector' style='float: left;width: 220px;padding-left: 10px;height:450px'>
+ {foreach from=$goalSegments key=segmentFamilyName item=segments}
+ {'Goals_ViewGoalsBySegment'|translate:$segmentFamilyName}
+ <ul class='listCircle'>
+ {foreach from=$segments item=segment}
+ <li title='{'Goals_ViewGoalsBySegment'|translate:$segment.name}' class='goalSegment' module='{$segment.module}' action='{$segment.action}'>
+ <span class='segment'>{$segment.name}</span>
+ </li>
+ {/foreach}
+ </ul>
+ {/foreach}
+</div>
+
+<div style='float: left;'>
+ {ajaxLoadingDiv id=tableGoalsLoading}
+
+ <div id='tableGoalsBySegment'></div>
+</div>
+<div style='clear:both'></div>
+{literal}
+<script type="text/javascript">
+$(document).ready( function() {
+ var countLoaded = 0;
+ /*
+ * For each 'segment' in the list, a click will trigger an ajax request to load the datatable
+ * showing Goals metrics (conversion, conv. rates, revenue) for this segment
+ */
+ $('.goalSegment').click( function() {
+ var self = this;
+ $('.goalSegment').removeClass('activeSegment');
+ $(this).addClass('activeSegment');
+ var module = $(this).attr('module');
+ var action = $(this).attr('action');
+ widgetUniqueId = module+action;
+ self.expectedWidgetUniqueId = widgetUniqueId;
+
+ var idGoal = broadcast.getValueFromHash('idGoal');
+ var widgetParameters = {
+ 'module': module,
+ 'action': action,
+ 'viewDataTable': 'tableGoals',
+ 'filter_only_display_idgoal': idGoal.length ? idGoal : 0 // 0 is Piwik_DataTable_Filter_UpdateColumnsWhenShowAllGoals::GOALS_FULL_TABLE
+ };
+ var onWidgetLoadedCallback = function (response) {
+ if(widgetUniqueId != self.expectedWidgetUniqueId) {
+ return;
+ }
+ $('#tableGoalsBySegment').html($(response));
+ $('#tableGoalsLoading').hide();
+ $('#tableGoalsBySegment').show();
+
+ countLoaded++;
+ // only scroll down to the loaded datatable if this is not the first one
+ // otherwise, screen would jump down to the table when loading the report
+ if(countLoaded > 1)
+ {
+ piwikHelper.lazyScrollTo("#titleGoalsBySegment", 400);
+ }
+ };
+ $('#tableGoalsBySegment').hide();
+ $('#tableGoalsLoading').show();
+ ajaxRequest = widgetsHelper.getLoadWidgetAjaxRequest(widgetUniqueId, widgetParameters, onWidgetLoadedCallback);
+ $.ajax(ajaxRequest);
+ });
+ $('.goalSegment').first().click();
+});
+</script>
+{/literal}
diff --git a/plugins/Goals/templates/title_and_evolution_graph.tpl b/plugins/Goals/templates/title_and_evolution_graph.tpl
index 8a344df003..0ac5707d00 100644
--- a/plugins/Goals/templates/title_and_evolution_graph.tpl
+++ b/plugins/Goals/templates/title_and_evolution_graph.tpl
@@ -1,18 +1,22 @@
<script type="text/javascript" src="plugins/CoreHome/templates/sparkline.js"></script>
<a name="evolutionGraph" graphId="{$nameGraphEvolution}"></a>
-<h2>{$title}</h2>
+
+{if $displayFullReport}
+ <h2>{if isset($goalName)}{'Goals_GoalX'|translate:$goalName}{else}{'Goals_GoalsOverview'|translate}{/if}</h2>
+{/if}
{$graphEvolution}
<div id='leftcolumn'>
<div class="sparkline">{sparkline src=$urlSparklineConversions}
- {'%s conversions'|translate:"<strong>$nb_conversions</strong>"}</div>
+ {'Goals_Conversions'|translate:"<strong>$nb_conversions</strong>"}</div>
{if $revenue != 0 }
<div class="sparkline">{sparkline src=$urlSparklineRevenue}
- {'%s overall revenue'|translate:"<strong>$currency$revenue</strong>"}</div>
+ {assign var=revenue value=$revenue|money:$idSite}
+ {'Goals_OverallRevenue'|translate:"<strong>$revenue</strong>"}</div>
{/if}
</div>
<div id='rightcolumn'>
<div class="sparkline">{sparkline src=$urlSparklineConversionRate}
- {'%s overall conversion rate (visits with a completed goal)'|translate:"<strong>$conversion_rate%</strong>"}</div>
+ {'Goals_OverallConversionRate'|translate:"<strong>$conversion_rate%</strong>"}</div>
</div>