Ticket #1120: #1120-#20100731-v2.patch

File #1120-#20100731-v2.patch, 7.9 KB (added by peterb, 22 months ago)

Show goal details per action; Highlight action field in the row, where conversion happened; + Minor Updates

  • plugins/Live/API.php

    ### Eclipse Workspace Patch 1.0
    #P trunk
     
    134134 
    135135                        $site = new Piwik_Site($idSite); 
    136136                        $timezone = $site->getTimezone(); 
     137                         
     138                        $visitorDetailsArray['siteCurrency'] = $site->getCurrency(); 
     139 
    137140                        $dateTimeVisit = Piwik_Date::factory($visitorDetailsArray['firstActionTimestamp'], $timezone); 
    138141                        $visitorDetailsArray['serverDatePretty'] = $dateTimeVisit->getLocalized('%shortDay% %day% %shortMonth%'); 
    139142                        $visitorDetailsArray['serverTimePretty'] = $dateTimeVisit->getLocalized('%time%'); 
    140143 
    141                         // get Detail - 100 single SQL Statements - Performance Issue 
     144                        if(!empty($visitorDetailsArray['goalTimePretty'])) { 
     145                                $dateTimeConversion = Piwik_Date::factory($visitorDetailsArray['goalTimePretty'], $timezone); 
     146                                $visitorDetailsArray['goalTimePretty'] = $dateTimeConversion->getLocalized('%shortDay% %day% %shortMonth% %time%'); 
     147                        } 
     148                         
    142149                        $idvisit = $visitorDetailsArray['idVisit']; 
    143150 
    144151                        $sql = " 
    145                                 SELECT DISTINCT " .Piwik_Common::prefixTable('log_action').".name AS pageUrl 
     152                                SELECT 
     153                                " .Piwik_Common::prefixTable('log_action').".name AS pageUrl, 
     154                                " .Piwik_Common::prefixTable('log_action').".idaction AS pageIdAction 
    146155                                FROM " .Piwik_Common::prefixTable('log_link_visit_action')." 
    147156                                        INNER JOIN " .Piwik_Common::prefixTable('log_action')." 
    148157                                        ON  " .Piwik_Common::prefixTable('log_link_visit_action').".idaction_url = " .Piwik_Common::prefixTable('log_action').".idaction 
     
    152161                        $visitorDetailsArray['actionDetails'] = Piwik_FetchAll($sql); 
    153162 
    154163                        $sql = " 
    155                                 SELECT DISTINCT " .Piwik_Common::prefixTable('log_action').".name AS pageUrl 
     164                                SELECT 
     165                                " .Piwik_Common::prefixTable('log_action').".name AS pageTitle, 
     166                                " .Piwik_Common::prefixTable('log_action').".idaction AS pageIdAction 
    156167                                FROM " .Piwik_Common::prefixTable('log_link_visit_action')." 
    157168                                        INNER JOIN " .Piwik_Common::prefixTable('log_action')." 
    158169                                        ON  " .Piwik_Common::prefixTable('log_link_visit_action').".idaction_name = " .Piwik_Common::prefixTable('log_action').".idaction 
     
    160171                                 "; 
    161172 
    162173                        $visitorDetailsArray['actionDetailsTitle'] = Piwik_FetchAll($sql); 
     174                         
    163175                        $table->addRowFromArray( array(Piwik_DataTable_Row::COLUMNS => $visitorDetailsArray)); 
    164176                } 
    165177 
     
    214226                } 
    215227 
    216228                $sql = "SELECT  " . Piwik_Common::prefixTable('log_visit') . ".* , 
    217                                                 " . Piwik_Common::prefixTable ( 'goal' ) . ".match_attribute 
     229                                                " . Piwik_Common::prefixTable ( 'goal' ) . ".match_attribute as goal_match_attribute, 
     230                                                " . Piwik_Common::prefixTable ( 'goal' ) . ".name as goal_name, 
     231                                                " . Piwik_Common::prefixTable ( 'goal' ) . ".revenue as goal_revenue, 
     232                                                " . Piwik_Common::prefixTable ( 'log_conversion' ) . ".idaction_url as goal_idaction_url, 
     233                                                " . Piwik_Common::prefixTable ( 'log_conversion' ) . ".server_time as goal_server_time 
    218234                                FROM " . Piwik_Common::prefixTable('log_visit') . " 
    219235                                        LEFT JOIN ".Piwik_Common::prefixTable('log_conversion')." 
    220236                                        ON " . Piwik_Common::prefixTable('log_visit') . ".idvisit = " . Piwik_Common::prefixTable('log_conversion') . ".idvisit 
     
    225241                                        $sqlWhere 
    226242                                ORDER BY idvisit DESC 
    227243                                LIMIT ".(int)$limit; 
    228  
    229244                return Piwik_FetchAll($sql, $whereBind); 
    230245        } 
    231246 
  • plugins/Live/templates/visitorLog.tpl

     
    108108                        {foreach from=$visitor.columns.actionDetails item=action} 
    109109                                <li> 
    110110                                        <a href="{$action.pageUrl}" target="_blank" style="text-decoration:underline;" title="{$action.pageUrl}">{$action.pageUrl|truncate:80:"...":true}</a> 
     111                                        {if $visitor.columns.goalUrl eq $action.pageIdAction} 
     112                                                <ul class="actionGoalDetails"> 
     113                                                        <li> 
     114                                                                <img src="{$visitor.columns.goalIcon}" title="{$visitor.columns.goalType}" /> <strong>{'Live_GoalMatch'|translate}</strong> | 
     115                                                                {'Live_GoalType'|translate}: <strong>{$visitor.columns.goalType}</strong> | 
     116                                                                {'Live_GoalName'|translate}: <strong>{$visitor.columns.goalName}</strong> | 
     117                                                                {if $visitor.columns.goalRevenue > 0}{'Live_GoalRevenue'|translate}: <strong>{$visitor.columns.goalRevenue} {$visitor.columns.siteCurrency}</strong> |{/if} 
     118                                                                {'Live_GoalTime'|translate}: <strong>{$visitor.columns.goalTimePretty}</strong> 
     119                                                                 
     120                                                        </li> 
     121                                                </ul> 
     122                                        {/if} 
    111123                                </li> 
    112124                        {/foreach} 
    113125                        </ol> 
  • lang/en.php

     
    587587        'Live_Time' => 'Time', 
    588588        'Live_Referrer_URL' => 'Referrer URL', 
    589589        'Live_Last30Minutes' => 'Last 30 minutes', 
     590        'Live_GoalMatch' => 'Matching goal', 
     591        'Live_GoalType' => 'Type', 
     592        'Live_GoalName' => 'Name', 
     593        'Live_GoalTime' => '1st Conversion time', 
     594        'Live_GoalRevenue' => 'Revenue', 
     595        'Live_GoalDetails' => 'Details', 
    590596        'Login_PluginDescription' => 'Login Authentication plugin, reading the credentials from the config/config.inc.php file for the Super User, and from the Database for the other users. Can be easily replaced to introduce a new Authentication mechanism (OpenID, htaccess, custom Auth, etc.).', 
    591597        'Login_LoginPasswordNotCorrect' => 'Username &amp; Password not correct', 
    592598        'Login_Password' => 'Password', 
  • plugins/Live/Visitor.php

     
    7878                        'isVisitorGoalConverted' => $this->isVisitorGoalConverted(), 
    7979                        'goalIcon' => $this->getGoalIcon(), 
    8080                        'goalType' => $this->getGoalType(), 
     81                        'goalName' => $this->getGoalName(), 
     82                        'goalRevenue' => $this->getGoalRevenue(), 
     83                        'goalUrl' => $this->getGoalUrl(), 
     84                        'goalTimePretty' => $this->getGoalTimePretty() 
    8185                ); 
    8286        } 
    8387 
     
    104108        { 
    105109                return $this->details['idsite']; 
    106110        } 
    107  
     111         
    108112        function getNumberOfActions() 
    109113        { 
    110114                return $this->details['visit_total_actions']; 
     
    318322 
    319323        function getGoalType() 
    320324        { 
    321                 if(isset($this->details['match_attribute'])){ 
    322                         return $this->details['match_attribute']; 
     325                if(isset($this->details['goal_match_attribute'])){ 
     326                        return ucfirst($this->details['goal_match_attribute']); 
    323327                } 
    324328                return false; 
    325329        } 
    326330 
    327331        function getGoalIcon() 
    328332        { 
    329                 if(isset($this->details['match_attribute'])){ 
     333                if(isset($this->details['goal_match_attribute'])){ 
    330334                        $goalicon = ""; 
    331                         switch ($this->details['match_attribute']) { 
     335                        switch ($this->details['goal_match_attribute']) { 
    332336                                case "url": 
    333337                                        $goalicon = "plugins/Live/templates/images/goal.png"; 
    334338                                        break; 
     
    343347                } 
    344348                return false; 
    345349        } 
     350         
     351        function getGoalName() 
     352        { 
     353                if(isset($this->details['goal_name'])){ 
     354                        return $this->details['goal_name']; 
     355                } 
     356                return false; 
     357        } 
     358         
     359        function getGoalRevenue() 
     360        { 
     361                if(isset($this->details['goal_revenue'])){ 
     362                        return $this->details['goal_revenue']; 
     363                } 
     364                return false; 
     365        } 
     366 
     367        function getGoalUrl() 
     368        { 
     369                if(isset($this->details['goal_idaction_url'])){ 
     370                        return $this->details['goal_idaction_url']; 
     371                } 
     372                return false; 
     373        } 
     374 
     375        function getGoalTimePretty() 
     376        { 
     377                if(isset($this->details['goal_server_time'])){ 
     378                        return $this->details['goal_server_time']; 
     379                } 
     380                return false; 
     381        } 
    346382} 
  • plugins/Live/templates/live.css

     
    5757 .visitsLiveFooter a.rightLink{ 
    5858         float:right; 
    5959         padding-right:20px; 
    60  } 
    61  No newline at end of file 
     60 } 
     61 .actionGoalDetails { 
     62        margin-left:20px; 
     63        padding-bottom:10px; 
     64        font-size:90%; 
     65} 
     66table.dataTable td.highlightField { 
     67        background-color:#FFFFCB !important; 
     68} 
     69  
     70 No newline at end of file