/** * Display a listing of the resource. * * @param null $path * @return Response */ public function generateReport($path = null) { $url = $path; $path = str_replace('/', '%2F', $path); $fillColor = 'rgba(151,187,205,0.2)'; $solidColor = 'rgba(151,187,205,1)'; $ga_metrics = ['pageviews' => 'Page Views', 'uniquePageviews' => 'Unique Page Views', 'avgTimeOnPage' => 'Avg Time On Page', 'entrances' => 'Entrances', 'bounceRate' => 'Bounce Rate', 'exitRate' => 'Exit Rate']; $startDate = new DateTime('30 days ago'); $endDate = new DateTime('today'); $metrics = 'ga:' . implode(',ga:', array_keys($ga_metrics)); $others = ['dimensions' => 'ga:pagePath,ga:date', 'filters' => 'ga:pagePath%3D%3D%2F' . $path]; $empty = false; $analytics = LaravelAnalyticsFacade::performQuery($startDate, $endDate, $metrics, $others); if (empty($analytics['totalResults'])) { $ga_total = $ga_dated = []; $ga_script = ''; $empty = true; return view('analytics', compact('ga_total', 'ga_dated', 'ga_script', 'url', 'empty')); } $ga_total = $analytics['totalsForAllResults']; $ga_dated = $this->generateGaDatedArray($analytics['rows']); $ga_script = '<script>'; foreach ($ga_metrics as $key => $value) { $ga_script .= $this->generateGaElementScript($key, $value, $ga_dated['ga_labels'], $ga_dated['ga_elements'][$key], $fillColor, $solidColor); } $ga_script .= $this->generateGaToggleChartScript($ga_metrics); $ga_script .= '</script>'; return view('analytics', compact('ga_total', 'ga_dated', 'ga_script', 'url', 'empty')); }
public function thisWeek() { try { return LaravelAnalytics::getVisitorsAndPageViewsForPeriod(Carbon::today()->subWeeks(1)->addDays(1), Carbon::today()); } catch (\Exception $e) { return false; } }
public function getActiveUser() { try { return is_numeric(LaravelAnalytics::getActiveUsers()) ? ['true', LaravelAnalytics::getActiveUsers()] : ['true', 0]; } catch (\Exception $e) { Logs::add('errors', trans("whole::http/controllers.analytics_log_errors_2")); return ['false', trans("whole::http/controllers.analytics_active_user_limit")]; } }
public function getActiveUser() { try { return is_numeric(LaravelAnalytics::getActiveUsers()) ? ['true', LaravelAnalytics::getActiveUsers()] : ['true', 0]; } catch (\Exception $e) { Logs::add('errors', "Anlık İstatistiklerde Beklenmeyen Hata! \nGünlük Veri İstek Limiti Aşıldı.\nAnlık Veriler Çekilemiyor"); return ['false', "Günlük İstek Limiti Aşıldı"]; } }
public function referrers() { $referrers = LaravelAnalyticsFacade::getTopReferrers(90, 5); $colours = RandomColor::many(10, array('hue' => 'green')); $values = $referrers->map(function ($page, $index) use($colours) { return ['value' => $page['pageViews'], "color" => $colours[$index * 2], "highlight" => $colours[$index * 2 + 1], 'label' => $page['url']]; }); return response()->json($values->toArray()); }
public function dashboard() { $totalVisitors = LaravelAnalyticsFacade::getVisitorsAndPageViews(30)->reduce(function ($carry, $day) { return $day['visitors'] + $carry; }, 0); $categories = PostCategory::with(['posts' => function ($query) { $query->where('published', 1); }])->get(); return view('admin.pages.dashboard')->with(compact('categories', 'totalVisitors')); }
public function main() { if (is_null(env('ANALYTICS_SITE_ID'))) { return view('quarx::dashboard.empty'); } foreach (LaravelAnalytics::getVisitorsAndPageViews(7) as $view) { $visitStats['date'][] = $view['date']->format('Y-m-d'); $visitStats['visitors'][] = $view['visitors']; $visitStats['pageViews'][] = $view['pageViews']; } return view('quarx::dashboard.analytics', compact('visitStats', 'oneYear')); }