protected function trackVisits()
 {
     $dateTime = $this->dateTime;
     $idSite = $this->idSite;
     $idGoal_OneConversionPerVisit = $this->idGoal_OneConversionPerVisit;
     $idGoal_MultipleConversionPerVisit = $this->idGoal_MultipleConversionPerVisit;
     $t = $this->getTracker($idSite, $dateTime, $defaultInit = true);
     // Record 1st goal, should only have 1 conversion
     $t->setUrl('http://example.org/index.htm');
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.3)->getDatetime());
     $this->checkResponse($t->doTrackPageView('Thank you mate'));
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.4)->getDatetime());
     $this->checkResponse($t->doTrackGoal($idGoal_OneConversionPerVisit, $revenue = 10000000));
     // Record 2nd goal, should record both conversions
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.5)->getDatetime());
     $this->checkResponse($t->doTrackGoal($idGoal_MultipleConversionPerVisit, $revenue = 300));
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.6)->getDatetime());
     $this->checkResponse($t->doTrackGoal($idGoal_MultipleConversionPerVisit, $revenue = 366));
     // Update & set to not allow multiple
     $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
     $goal = $goals[$idGoal_OneConversionPerVisit];
     $this->assertTrue($goal['allow_multiple'] == 0);
     Piwik_Goals_API::getInstance()->updateGoal($idSite, $idGoal_OneConversionPerVisit, $goal['name'], @$goal['match_attribute'], @$goal['pattern'], @$goal['pattern_type'], @$goal['case_sensitive'], $goal['revenue'], $goal['allow_multiple'] = 1);
     $this->assertTrue($goal['allow_multiple'] == 1);
     // 1st goal should Now be tracked
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.61)->getDatetime());
     $this->checkResponse($t->doTrackGoal($idGoal_OneConversionPerVisit, $revenue = 656));
 }
Beispiel #2
0
 public function setColumnsToDisplay($columnsNames)
 {
     $newColumnsNames = array();
     $goals = array();
     $idSite = $this->getIdSite();
     if ($idSite) {
         $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
     }
     foreach ($columnsNames as $columnName) {
         if (in_array($columnName, array('goal_%s_conversion_rate', 'goal_%s_nb_conversions', 'goal_%s_revenue_per_visit'))) {
             foreach ($goals as $goal) {
                 $idgoal = $goal['idgoal'];
                 if ($this->processOnlyIdGoal > Piwik_DataTable_Filter_AddColumnsProcessedMetricsGoal::GOALS_FULL_TABLE && $this->processOnlyIdGoal != $idgoal) {
                     continue;
                 }
                 $name = Piwik_Translate($this->getColumnTranslation($columnName), $goal['name']);
                 $columnNameGoal = str_replace('%s', $idgoal, $columnName);
                 $this->setColumnTranslation($columnNameGoal, $name);
                 if (strstr($columnNameGoal, '_rate') === false && $this->processOnlyIdGoal == Piwik_DataTable_Filter_AddColumnsProcessedMetricsGoal::GOALS_OVERVIEW) {
                     continue;
                 }
                 if (strstr($columnNameGoal, '_revenue') !== false) {
                     $this->columnsToRevenueFilter[] = $columnNameGoal;
                 } else {
                     $this->columnsToConversionFilter[] = $columnNameGoal;
                 }
                 $newColumnsNames[] = $columnNameGoal;
             }
         } else {
             $newColumnsNames[] = $columnName;
         }
     }
     parent::setColumnsToDisplay($newColumnsNames);
 }
 protected static function setUpWebsitesAndGoals()
 {
     self::createWebsite(self::$dateTime, $ecommerce = 1);
     Piwik_Goals_API::getInstance()->addGoal(self::$idSite, 'Goal 1 - Thank you', 'title', 'Thank you', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = 1);
     Piwik_Goals_API::getInstance()->addGoal(self::$idSite, 'Goal 2 - Hello', 'url', 'hellow', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = 0);
     Piwik_Goals_API::getInstance()->addGoal(self::$idSite, 'triggered js', 'manually', '', '');
 }
Beispiel #4
0
 public function setUp()
 {
     parent::setUp();
     $this->idSite = $this->createWebsite($this->dateTime);
     // for conversion testing
     $this->idGoal = Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
 }
Beispiel #5
0
 /**
  * @return Piwik_Goals_API
  */
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Beispiel #6
0
	public function setColumnsToDisplay($columnsNames)
	{
		$newColumnsNames = array();
		foreach($columnsNames as $columnName)
		{
			if($columnName == 'goal_%s_conversion_rate')
			{
				$goals = Piwik_Goals_API::getGoals( $this->getIdSite() );
				foreach($goals as $goal)
				{
					$idgoal = $goal['idgoal'];
					$name = $goal['name'];
					$columnName = 'goal_'.$idgoal.'_conversion_rate';
					$newColumnsNames[] = $columnName;
					$this->setColumnTranslation($columnName, $name);
					$this->columnsToPercentageFilter[] = $columnName;
				}
			}
			else
			{
				$newColumnsNames[] = $columnName;
			}
		}
		parent::setColumnsToDisplay($newColumnsNames);
	}
 protected static function trackVisits()
 {
     // tests run in UTC, the Tracker in UTC
     $dateTime = self::$dateTime;
     $idSite = self::$idSite;
     $t = self::getTracker($idSite, $dateTime, $defaultInit = true, $useThirdPartyCookie = 1);
     // Also testing to record this as a bot while specifically allowing bots
     $t->setUserAgent('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
     $t->DEBUG_APPEND_URL .= '&bots=1';
     $t->DEBUG_APPEND_URL .= '&forceIpAnonymization=1';
     // VISIT 1 = Referrer is "Keyword not defined"
     // Alsotrigger goal to check that attribution goes to this keyword
     $t->setUrlReferrer('http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CC&url=http%3A%2F%2Fpiwik.org%2F&ei=&usg=');
     $t->setUrl('http://example.org/this%20is%20cool!');
     self::checkResponse($t->doTrackPageView('incredible title!'));
     $idGoal = Piwik_Goals_API::getInstance()->addGoal($idSite, 'triggered js', 'manually', '', '');
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.3)->getDatetime());
     self::checkResponse($t->doTrackGoal($idGoal, $revenue = 42));
     // VISIT 2 = Referrer has keyword, but the URL should be rewritten
     // in Live Output to point to google search result page
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(2)->getDatetime());
     $t->setUrlReferrer('http://www.google.com.vn/url?sa=t&rct=j&q=%3C%3E%26%5C%22the%20pdo%20extension%20is%20required%20for%20this%20adapter%20but%20the%20extension%20is%20not%20loaded&source=web&cd=4&ved=0FjAD&url=http%3A%2F%2Fforum.piwik.org%2Fread.php%3F2%2C1011&ei=y-HHAQ&usg=AFQjCN2-nt5_GgDeg&cad=rja');
     // Test with empty title, that the output of Live is valid
     self::checkResponse($t->doTrackPageView(''));
 }
 protected static function setUpWebsitesAndGoals()
 {
     // tests run in UTC, the Tracker in UTC
     self::createWebsite(self::$dateTime);
     Piwik_Goals_API::getInstance()->addGoal(self::$idSite, 'triggered js', 'manually', '', '');
     Piwik_Goals_API::getInstance()->addGoal(self::$idSite, 'second goal', 'manually', '', '');
 }
Beispiel #9
0
 function fetchGoalsFromDb($notification)
 {
     $idsite = $notification->getNotificationInfo();
     // add the 'goal' entry in the website array
     $array =& $notification->getNotificationObject();
     $array['goals'] = Piwik_Goals_API::getInstance()->getGoals($idsite);
 }
 public function setUp()
 {
     parent::setUp();
     $this->idSite = $this->createWebsite($this->dateTime, $ecommerce = 1);
     $this->idGoal = Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'Goal 1 - Thank you', 'title', 'Thank you', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = 1);
     $this->idGoal2 = Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'Goal 2 - Hello', 'url', 'hellow', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = 0);
     $this->idGoal3 = Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
 }
 public function setUp()
 {
     parent::setUp();
     // tests run in UTC, the Tracker in UTC
     $this->idSite = $this->createWebsite($this->dateTime);
     $this->idGoal1 = Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'triggered js', 'manually', '', '');
     $this->idGoal2 = Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'second goal', 'manually', '', '');
 }
Beispiel #12
0
 public static function getInstance()
 {
     if (self::$instance == null) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
 public function setUp()
 {
     parent::setUp();
     $this->dateTime = '2011-04-05 00:11:42';
     $this->idSite = $this->createWebsite($this->dateTime, $ecommerce = 1);
     $this->idSite2 = $this->createWebsite($this->dateTime);
     $this->idGoalStandard = Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'title match, triggered ONCE', 'title', 'incredible', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = true);
 }
Beispiel #14
0
 function fetchGoalsFromDb($notification)
 {
     require_once "Goals/API.php";
     $idsite = $notification->getNotificationInfo();
     // add the 'goal' entry in the website array
     $array =& $notification->getNotificationObject();
     $array['goals'] = Piwik_Goals_API::getGoals($idsite);
 }
 protected function trackVisitsImpl($t)
 {
     $dateTime = $this->dateTime;
     $idSite = $this->idSite;
     $t->disableCookieSupport();
     $t->setUrlReferrer('http://referer.com/page.htm?param=valuewith some spaces');
     // testing URL excluded parameters
     $parameterToExclude = 'excluded_parameter';
     Piwik_SitesManager_API::getInstance()->updateSite($idSite, 'new name', $url = array('http://site.com'), $ecommerce = 0, $excludedIps = null, $parameterToExclude . ',anotherParameter');
     // Record 1st page view
     $urlPage1 = 'http://example.org/index.htm?excluded_Parameter=SHOULD_NOT_DISPLAY&parameter=Should display';
     $t->setUrl($urlPage1);
     $this->checkResponse($t->doTrackPageView('incredible title!'));
     // testing that / and index.htm above record with different URLs
     // Recording the 2nd page after 3 minutes
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.05)->getDatetime());
     $urlPage2 = 'http://example.org/';
     $t->setUrl($urlPage2);
     //		$t->setUrlReferrer($urlPage1);
     $this->checkResponse($t->doTrackPageView('Second page view - should be registered as URL /'));
     //		$t->setUrlReferrer($urlPage2);
     // Click on external link after 6 minutes (3rd action)
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.1)->getDatetime());
     $this->checkResponse($t->doTrackAction('http://dev.piwik.org/svn', 'link'));
     // Click on file download after 12 minutes (4th action)
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.2)->getDatetime());
     $this->checkResponse($t->doTrackAction('http://piwik.org/path/again/latest.zip', 'download'));
     // 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());
     // Change to Thai  browser to ensure the conversion is credited to FR instead (the visitor initial country)
     $t->setBrowserLanguage('th');
     $this->checkResponse($t->doTrackGoal($idGoal, $revenue = 42));
     // Track same Goal twice (after 24 minutes), should only be tracked once
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.4)->getDatetime());
     $this->checkResponse($t->doTrackGoal($idGoal, $revenue = 42));
     $t->setBrowserLanguage('fr');
     // Final page view (after 27 min)
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(0.45)->getDatetime());
     $t->setUrl('http://example.org/index.htm');
     $this->checkResponse($t->doTrackPageView('Looking at homepage (again)...'));
     // -
     // End of first visit: 24min
     // Create Goal 2: Matching on URL
     Piwik_Goals_API::getInstance()->addGoal($idSite, 'matching purchase.htm', 'url', '(.*)store\\/purchase\\.(.*)', 'regex', false, $revenue = 1);
     // -
     // Start of returning visit, 1 hour after first page view
     $t->setForceVisitDateTime(Piwik_Date::factory($dateTime)->addHour(1)->getDatetime());
     $t->setUrl('http://example.org/store/purchase.htm');
     $t->setUrlReferrer('http://search.yahoo.com/search?p=purchase');
     // Temporary, until we implement 1st party cookies in PiwikTracker
     $t->DEBUG_APPEND_URL = '&_idvc=2';
     // Goal Tracking URL matching, testing custom referer including keyword
     $this->checkResponse($t->doTrackPageView('Checkout/Purchasing...'));
     // -
     // End of second visit
 }
Beispiel #16
0
 function addNewExperiment()
 {
     $view = Piwik_View::factory('add_new_experiment');
     $this->setGeneralVariablesView($view);
     $view->userCanEditExperiments = Piwik::isUserHasAdminAccess($this->idSite);
     $view->goalsPluginDeactived = !Piwik_PluginsManager::getInstance()->isPluginActivated('Goals');
     $view->goals = Piwik_Goals_API::getInstance()->getGoals($this->idSite);
     $view->onlyShowAddNewExperiment = true;
     echo $view->render();
 }
 protected static function setUpWebsitesAndGoals()
 {
     // tests run in UTC, the Tracker in UTC
     $ecommerce = self::$allowConversions ? 1 : 0;
     self::createWebsite(self::$dateTime, $ecommerce, "Site 1");
     self::createWebsite(self::$dateTime, 0, "Site 2");
     if (self::$allowConversions) {
         Piwik_Goals_API::getInstance()->addGoal(self::$idSite1, 'all', 'url', 'http', 'contains', false, 5);
         Piwik_Goals_API::getInstance()->addGoal(self::$idSite2, 'all', 'url', 'http', 'contains');
     }
 }
Beispiel #18
0
 public function getGoalsWithoutFunnels($idSite)
 {
     $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
     $funnelsByGoal = $this->getFunnelsByGoal($idSite);
     $goalsWithoutFunnels = array();
     foreach ($goals as &$goal) {
         if (!array_key_exists($goal['idgoal'], $funnelsByGoal)) {
             $goalsWithoutFunnels[$goal['idgoal']] = $goal;
         }
     }
     return $goalsWithoutFunnels;
 }
Beispiel #19
0
 function addMenus()
 {
     $idSite = Piwik_Common::getRequestVar('idSite');
     $experiments = Piwik_ABTests_API::getInstance()->getExperiments($idSite);
     $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
     if (count($experiments) == 0 && count($goals) > 0) {
         Piwik_AddMenu(Piwik_Translate('ABTests_ABTests'), Piwik_Translate('ABTests_CreateExperiment'), array('module' => 'ABTests', 'action' => 'addNewExperiment'));
     } elseif (count($experiments) == 0) {
         # messge saying you need goals to create experiments
     } else {
         Piwik_AddMenu('ABTests_ABTests', 'ABTests_Overview', array('module' => 'ABTests'));
         foreach ($experiments as $experiment) {
             Piwik_AddMenu('ABTests_ABTests', str_replace('%', '%%', $experiment['name']), array('module' => 'ABTests', 'action' => 'experimentReport', 'idExperiment' => $experiment['idexperiment']));
         }
     }
 }
 public function setUp()
 {
     $sitesManager = Piwik_SitesManager_API::getInstance();
     $goals = Piwik_Goals_API::getInstance();
     // add one thousand sites
     $allIdSites = array();
     for ($i = 0; $i < 1000; ++$i) {
         $allIdSites[] = IntegrationTestCase::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #{$i}");
     }
     // add goals to 500 sites
     $idGoals = array();
     foreach ($allIdSites as $idSite) {
         if ($idSite % 2 == 0) {
             $idGoal1 = $goals->addGoal($idSite, 'all', 'url', 'http', 'contains', false, 5);
             $idGoal2 = $goals->addGoal($idSite, 'all', 'url', 'http', 'contains');
             $idGoals[$idSite] = array($idGoal1, $idGoal2);
         } else {
             $idGoals[$idSite] = array();
         }
     }
     $urls = array();
     for ($i = 0; $i != 3; ++$i) {
         $url = "http://whatever.com/" . ($i - 1) . "/" . ($i + 1);
         $title = "page view " . ($i - 1) . " / " . ($i + 1);
         $urls[$url] = $title;
     }
     $visitTimes = array();
     $date = Piwik_Date::factory($this->date);
     for ($i = 0; $i != 4; ++$i) {
         $visitTimes[] = $date->addHour($i)->getDatetime();
     }
     // add 12000 visits (3 visitors with 4 visits each for each site) w/ 3 pageviews each on one day
     foreach ($visitTimes as $visitTime) {
         foreach ($allIdSites as $idSite) {
             for ($visitor = 0; $visitor != 3; ++$visitor) {
                 $t = BenchmarkTestCase::getLocalTracker($this->idSite);
                 $ip = "157.5.6." . ($visitor + 1);
                 $t->setIp($ip);
                 $t->setForceVisitDateTime($visitTime);
                 foreach ($urls as $url => $title) {
                     $t->setUrl($url);
                     $t->doTrackPageView($title);
                 }
             }
         }
     }
 }
 public function setUp()
 {
     $this->idSite = $this->createWebsite($this->dateTime, 1, "Site #0");
     // add one goal
     $this->idGoal = Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'all', 'url', 'http', 'contains');
     for ($i = 0; $i != 10; ++$i) {
         $this->urls[] = "http://whatever.com/" . ($i - 1) . "/" . ($i + 1);
         $this->titles[] = "page view " . ($i - 1) . " / " . ($i + 1);
     }
     $this->tracker = $this->getTracker($this->idSite, $this->dateTime);
     $date = Piwik_Date::factory($this->dateTime);
     for ($i = 0; $i != 10; ++$i) {
         for ($j = 0; $j != 10; ++$j) {
             $this->visitDates[] = $date->addDay($i)->addHour($j)->toString();
         }
     }
 }
Beispiel #22
0
 public function setColumnsToDisplay($columnsNames)
 {
     $newColumnsNames = array();
     $goals = array();
     $idSite = $this->getIdSite();
     if ($idSite) {
         $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
         $ecommerceGoal = array('idgoal' => Piwik_Archive::LABEL_ECOMMERCE_ORDER, 'name' => Piwik_Translate('Goals_EcommerceOrder'));
         $site = new Piwik_Site($idSite);
         //Case Ecommerce report table
         if ($this->isEcommerce) {
             $goals = array($ecommerceGoal);
         } elseif ($site->isEcommerceEnabled()) {
             $goals = array_merge(array($ecommerceGoal), $goals);
         }
     }
     foreach ($columnsNames as $columnName) {
         if (in_array($columnName, array('goal_%s_conversion_rate', 'goal_%s_nb_conversions', 'goal_%s_revenue_per_visit', 'goal_%s_revenue', 'goal_%s_avg_order_revenue', 'goal_%s_items'))) {
             foreach ($goals as $goal) {
                 $idgoal = $goal['idgoal'];
                 // Columns names are escaped in smarty via | escape:'html'
                 $goal['name'] = Piwik_Common::unsanitizeInputValue($goal['name']);
                 if ($this->processOnlyIdGoal > Piwik_DataTable_Filter_AddColumnsProcessedMetricsGoal::GOALS_FULL_TABLE && $this->processOnlyIdGoal != $idgoal && !$this->isEcommerce) {
                     continue;
                 }
                 $name = Piwik_Translate($this->getColumnTranslation($columnName), $goal['name']);
                 $columnNameGoal = str_replace('%s', $idgoal, $columnName);
                 $this->setColumnTranslation($columnNameGoal, $name);
                 $this->setDynamicMetricDocumentation($columnName, $columnNameGoal, $goal['name'], $goal['idgoal']);
                 if (strpos($columnNameGoal, '_rate') === false && $this->processOnlyIdGoal == Piwik_DataTable_Filter_AddColumnsProcessedMetricsGoal::GOALS_OVERVIEW) {
                     continue;
                 }
                 if (strstr($columnNameGoal, '_revenue') !== false) {
                     $this->columnsToRevenueFilter[] = $columnNameGoal;
                 } else {
                     $this->columnsToConversionFilter[] = $columnNameGoal;
                 }
                 $newColumnsNames[] = $columnNameGoal;
             }
         } else {
             $newColumnsNames[] = $columnName;
         }
     }
     parent::setColumnsToDisplay($newColumnsNames);
 }
Beispiel #23
0
 public function test_addFunnel()
 {
     $idSite = Piwik_SitesManager_API::getInstance()->addSite("test site", "http://www.example.com");
     $idGoal = Piwik_Goals_API::getInstance()->addGoal($idSite, "test goal", 'url', 'test', 'contains', 0, 0);
     $steps = array(1 => array('name' => 'step one', 'url' => 'http://www.example.com/step_one', 'id' => 1));
     $idFunnel = Piwik_Funnels_API::getInstance()->addFunnel($idSite, $idGoal, $steps);
     $this->assertIsA($idFunnel, 'int');
     $funnels = Piwik_Funnels_API::getInstance()->getFunnels($idSite);
     $this->assertTrue(count($funnels) === 1);
     $funnel = $funnels[$idFunnel];
     $this->assertEqual($funnel['idsite'], $idSite);
     $this->assertEqual($funnel['idgoal'], $idGoal);
     $steps = $funnel['steps'];
     $this->assertTrue(count($steps) === 1);
     $step = $steps[0];
     $this->assertEqual($step['name'], 'step one');
     $this->assertEqual($step['url'], 'http://www.example.com/step_one');
     $this->assertEqual($step['idstep'], 1);
 }
 public function setUp()
 {
     // add one site
     IntegrationTestCase::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/");
     // add two goals
     $goals = Piwik_Goals_API::getInstance();
     $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
     $goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains');
     $urls = array();
     for ($i = 0; $i != 3; ++$i) {
         $url = "http://whatever.com/" . ($i - 1) . "/" . ($i + 1);
         $title = "page view " . ($i - 1) . " / " . ($i + 1);
         $urls[$url] = $title;
     }
     $visitTimes = array();
     $date = Piwik_Date::factory($this->date);
     for ($month = 0; $month != 12; ++$month) {
         for ($day = 0; $day != 25; ++$day) {
             $hour = $time * 31 / 60.0;
             $visitTimes[] = $date->addPeriod($month, 'MONTH')->addDay($day)->getDatetime();
         }
     }
     // add 12,000 visits (1 visit a day from 40 visitors for 25 days of every month) w/ 3 pageviews each
     foreach ($visitTimes as $visitTime) {
         for ($visitor = 0; $visitor != 40; ++$visitor) {
             $t = BenchmarkTestCase::getLocalTracker($this->idSite);
             $ip = "157.5.6." . ($visitor + 1);
             $t->setIp($ip);
             $t->setForceVisitDateTime($visitTime);
             foreach ($urls as $url => $title) {
                 $t->setUrl($url);
                 $t->doTrackPageView($title);
             }
         }
     }
 }
 private function addLogData()
 {
     // tracks visits on the following days:
     // - 2012-01-09
     // - 2012-01-14
     // - 2012-01-19
     // - 2012-01-24 <--- everything before this date is to be purged
     // - 2012-01-29
     // - 2012-02-03
     // - 2012-02-08
     // - 2012-02-13
     // - 2012-02-18
     // - 2012-02-23
     // - 2012-02-28
     // 6 visits in feb, 5 in jan
     // following actions are created:
     // - 'First page view'
     // - 'Second page view'
     // - 'SKU2'
     // - 'Canon SLR'
     // - 'Electronics & Cameras'
     // - for every visit (11 visits total):
     //   - http://whatever.com/_{$daysSinceLastVisit}
     //   - http://whatever.com/42/{$daysSinceLastVisit}
     $start = $this->dateTime;
     $this->idSite = $this->createWebsite('2012-01-01', $ecommerce = 1);
     $idGoal = Piwik_Goals_API::getInstance()->addGoal($this->idSite, 'match all', 'url', 'http', 'contains');
     for ($daysAgo = $this->daysAgoStart; $daysAgo >= 0; $daysAgo -= 5) {
         $dateTime = $start->subDay($daysAgo)->toString();
         $t = $this->getTracker($this->idSite, $dateTime, $defaultInit = true);
         $t->setUserAgent('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)');
         // use $daysAgo to make sure new actions are created for every day and aren't used again.
         // when deleting visits, some of these actions will no longer be referenced in the DB.
         $t->setUrl("http://whatever.com/_{$daysAgo}");
         $t->doTrackPageView('First page view');
         $t->setUrl("http://whatever.com/42/{$daysAgo}");
         $t->doTrackPageView('Second page view');
         $t->addEcommerceItem($sku = 'SKU2', $name = 'Canon SLR', $category = 'Electronics & Cameras', $price = 1500, $quantity = 1);
         $t->doTrackEcommerceOrder($orderId = '937nsjusu ' . $dateTime, $grandTotal = 1111.11, $subTotal = 1000, $tax = 111, $shipping = 0.11, $discount = 666);
     }
 }
Beispiel #26
0
 function __construct()
 {
     parent::__construct();
     $this->idSite = Piwik_Common::getRequestVar('idSite');
     $this->goals = Piwik_Goals_API::getInstance()->getGoals($this->idSite);
 }
 public static function setUpWebsitesAndGoals()
 {
     self::createWebsite(self::$dateTime, $ecommerce = 1);
     self::createWebsite(self::$dateTime);
     Piwik_Goals_API::getInstance()->addGoal(self::$idSite, 'title match, triggered ONCE', 'title', 'incredible', 'contains', $caseSensitive = false, $revenue = 10, $allowMultipleConversions = true);
 }
 public function test_archiveGoals()
 {
     Piwik_Goals_API::get($this->idSite, 'year', $this->dateTime);
 }
Beispiel #29
0
 function addMenus()
 {
     $idSite = Piwik_Common::getRequestVar('idSite', null, 'int');
     $goals = Piwik_Goals_API::getInstance()->getGoals($idSite);
     $mainGoalMenu = $this->getGoalCategoryName($idSite);
     $site = new Piwik_Site($idSite);
     if (count($goals) == 0) {
         Piwik_AddMenu($mainGoalMenu, '', array('module' => 'Goals', 'action' => $site->isEcommerceEnabled() ? 'ecommerceReport' : 'addNewGoal', 'idGoal' => $site->isEcommerceEnabled() ? Piwik_Archive::LABEL_ECOMMERCE_ORDER : null), true, 25);
         if ($site->isEcommerceEnabled()) {
             Piwik_AddMenu($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik_Archive::LABEL_ECOMMERCE_ORDER), true, 1);
         }
         Piwik_AddMenu($mainGoalMenu, 'Goals_AddNewGoal', array('module' => 'Goals', 'action' => 'addNewGoal'));
     } else {
         Piwik_AddMenu($mainGoalMenu, '', array('module' => 'Goals', 'action' => $site->isEcommerceEnabled() ? 'ecommerceReport' : 'index', 'idGoal' => $site->isEcommerceEnabled() ? Piwik_Archive::LABEL_ECOMMERCE_ORDER : null), true, 25);
         if ($site->isEcommerceEnabled()) {
             Piwik_AddMenu($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik_Archive::LABEL_ECOMMERCE_ORDER), true, 1);
         }
         Piwik_AddMenu($mainGoalMenu, 'Goals_GoalsOverview', array('module' => 'Goals', 'action' => 'index'), true, 2);
         foreach ($goals as $goal) {
             Piwik_AddMenu($mainGoalMenu, str_replace('%', '%%', Piwik_TranslationWriter::clean($goal['name'])), array('module' => 'Goals', 'action' => 'goalReport', 'idGoal' => $goal['idgoal']));
         }
     }
 }
 public function test_archiveGoals_andQueryAll()
 {
     Piwik_Goals_API::get('all', 'day', $this->dateTime);
 }