/**
  * 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'));
 }