예제 #1
0
파일: API.php 프로젝트: rajerino/funnels
 public function addFunnel($idSite, $idGoal, $steps)
 {
     Piwik::checkUserHasAdminAccess($idSite);
     // save in db
     $idFunnel = Piwik_FetchOne("SELECT max(idfunnel) + 1 \n\t\t\t\t\t\t     \t\tFROM " . Piwik_Common::prefixTable('funnel') . " \n\t\t\t\t\t\t\t     \tWHERE idsite = ?", $idSite);
     if ($idFunnel == false) {
         $idFunnel = 1;
     }
     Piwik_Query("INSERT INTO " . Piwik_Common::prefixTable('funnel') . "\n\t\t\t\t\t(idsite, idgoal, idfunnel)\n\t\t\t\t\tVALUES (?, ?, ?)", array($idSite, $idGoal, $idFunnel));
     Piwik_Tracker_Cache::regenerateCacheWebsiteAttributes($idSite);
     $this->updateFunnel($idSite, $idGoal, $idFunnel, $steps);
     return $idFunnel;
 }
예제 #2
0
 public static function setBrowserTriggerArchiving($enabled)
 {
     if (!is_bool($enabled)) {
         throw new Exception('Browser trigger archiving must be set to true or false.');
     }
     Piwik_SetOption(self::OPTION_BROWSER_TRIGGER_ARCHIVING, (int) $enabled, $autoload = true);
     Piwik_Tracker_Cache::clearCacheGeneral();
 }
예제 #3
0
 function doStepMatchAndSave($idSite, $idVisit, $idRefererAction, $actionName = "", $actionUrl = "", $idActionUrl = Piwik_Funnels::INDEX_MANUAL_CONVERSION)
 {
     printDebug('Looking for funnel steps');
     $websiteAttributes = Piwik_Tracker_Cache::getCacheWebsiteAttributes($idSite);
     if (isset($websiteAttributes['funnels'])) {
         $funnels = $websiteAttributes['funnels'];
         printDebug('got funnel steps');
     } else {
         $funnels = array();
     }
     if (count($funnels) <= 0) {
         return;
     }
     printDebug("idActionUrl " . $idActionUrl . " idSite " . $idSite . " idVisit " . $idVisit . " idRefererAction " . $idRefererAction);
     // Is this the next action for a recorded funnel step?
     $previous_step_action = Piwik_Query("UPDATE " . Piwik_Common::prefixTable('log_funnel_step') . "\n            SET   idaction_url_next = ?\n            WHERE idsite = ? \n            AND   idvisit = ? \n            AND   idaction_url = ?\n            AND   idaction_url_next is null", array($idActionUrl, $idSite, $idVisit, $idRefererAction));
     // early out for special case of manual conversion
     // Since this is a manual conversion for a goal, there is no URL to
     // match with, so the following loop is simply a waste of resources
     if ($idActionUrl == Piwik_Funnels::INDEX_MANUAL_CONVERSION) {
         return;
     }
     foreach ($funnels as &$funnel) {
         $steps = $funnel['steps'];
         foreach ($steps as &$step) {
             $url = $actionUrl;
             // Matching on Page Title
             if ($step['match_attribute'] == 'title') {
                 $url = $actionName;
             }
             if (self::isMatch($url, $step['pattern_type'], $step['url'], $step['case_sensitive'])) {
                 printDebug("Matched Goal Funnel " . $funnel['idfunnel'] . " Step " . $step['idstep'] . "(name: " . $step['name'] . ", url: " . $step['url'] . "). ");
                 $serverTime = time();
                 $datetimeServer = Piwik_Tracker::getDatetimeFromTimestamp($serverTime);
                 // Look to see if this step has already been recorded for this visit
                 $exists = Piwik_FetchOne("SELECT *\n                        FROM " . Piwik_Common::prefixTable('log_funnel_step') . " \n                        WHERE idsite = ? \n                        AND   idfunnel = ?\n                        AND   idstep = ?\n                        AND   idvisit = ?", array($idSite, $funnel['idfunnel'], $step['idstep'], $idVisit));
                 // Record it if not
                 if (!$exists) {
                     printDebug("Recording...");
                     Piwik_Query("INSERT INTO " . Piwik_Common::prefixTable('log_funnel_step') . "\n                            (idvisit, idsite, idaction_url, url, \n                            idgoal, idfunnel, idstep, \n                            idaction_url_ref, server_time)\n                            VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", array($idVisit, $idSite, $idActionUrl, $url, $funnel['idgoal'], $step['idfunnel'], $step['idstep'], $idRefererAction, $datetimeServer));
                 }
             }
         }
     }
 }