/**
  * Attribution pixel
  *
  * @param  PixelRequest $request
  * @return Image
  */
 public function store(PixelRequest $request)
 {
     $this->agent->setUserAgent($request->header('user-agent'));
     ignore_user_abort(true);
     // Turn off gzip compression
     if (function_exists('apache_setenv')) {
         apache_setenv('no-gzip', 1);
     }
     ini_set('zlib.output_compression', 0);
     // Turn on output buffering if necessary
     if (ob_get_level() == 0) {
         ob_start();
     }
     // Remove any content encoding
     header('Content-encoding: none', true);
     if (!$request->isMethod('post')) {
         // Create attribution entry
         $attribution = Attribution::create(['landing_page_id' => $request->get('lp'), 'email' => $request->get('em'), 'tracking_id' => $request->get('t'), 'converting_source' => $request->get('cs'), 'converting_medium' => $request->get('cm'), 'converting_keyword' => $request->get('ck'), 'converting_content' => $request->get('ccn'), 'converting_campaign' => $request->get('cc'), 'converting_landing_page' => $request->get('cl'), 'converting_timestamp' => Carbon::createFromTimeStamp($request->get('ct'))->toDateTimeString(), 'original_source' => $request->get('os'), 'original_medium' => $request->get('om'), 'original_keyword' => $request->get('ok'), 'original_content' => $request->get('ocn'), 'original_campaign' => $request->get('oc'), 'original_landing_page' => $request->get('ol'), 'original_timestamp' => Carbon::createFromTimeStamp($request->get('ot'))->toDateTimeString(), 'refer_url' => $request->get('r'), 'platform' => $this->agent->platform(), 'device' => $this->agent->device(), 'browser' => $this->agent->browser(), 'version' => $this->agent->version($this->agent->browser())]);
         // Link attribution entry to lead
         \Event::fire(new AttributionSubmitted($attribution));
         // Return 1x1 pixel transparent gif
         header("Content-type: image/gif");
         header("Content-Length: 42");
         header("Cache-Control: private, no-cache, no-cache=Set-Cookie, proxy-revalidate");
         header("Pragma: no-cache");
         echo base64_decode('R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEA');
     }
     // Flush output buffers
     ob_flush();
     flush();
     ob_end_flush();
 }
 /**
  * Handle the event.
  *
  * @param  LeadSubmitted  $event
  * @return Boolean
  */
 public function handle(LeadSubmitted $event)
 {
     // Query for attribution entry if available
     $attribution = Attribution::where('landing_page_id', $event->lead->landing_page_id)->where('email', $event->lead->email)->where('lead_id', 0)->orderBy('created_at', 'DESC')->first();
     // If attribution entry is found already, set the lead id
     if (!is_null($attribution)) {
         $attribution->lead_id = $event->lead->id;
         $event->lead->has_attribution = true;
         $attribution->save();
         $event->lead->save();
     }
     return true;
 }
Beispiel #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  AdminDestroyRequest $request
  * @param  Integer $id
  * @return Response
  */
 public function destroy(AdminDestroyRequest $request, $id)
 {
     $lead = Lead::findOrFail($id);
     if (strtolower($request->get('fullname')) == strtolower($lead->fullname)) {
         $lead->delete();
         Attribution::where('lead_id', $id)->delete();
         return redirect('leads')->with('status', \Lang::get('lead.destroy.successful', ['fullname' => $lead->fullname]));
     } else {
         return redirect('leads/' . $lead->id . '/delete')->with('status', \Lang::get('lead.destroy.unsuccessful', ['fullname' => $lead->fullname]));
     }
 }
 /**
  * Display the specified resource.
  *
  * @param  ShowRequest $request
  * @param  Integer  $id
  * @return Response
  */
 public function show(ShowRequest $request, ChartContract $chart, $id)
 {
     $campaign = Campaign::where('id', $id)->with(['landing_pages' => function ($q) {
         $q->orderBy('created_at', 'DESC');
     }])->with(['comments' => function ($q) {
         $q->orderBy('created_at', 'DESC');
     }])->first();
     // Instantiate campaign leads collection
     $campaign->leads_data = collect();
     // Set chart date
     $chart->init($this->start_date, $this->end_date);
     // Add an iterator loop for different chart colors
     foreach ($campaign->landing_pages as $i => $landing_page) {
         // Get total lead count for date range
         $landing_page->leads_sum = $landing_page->leads()->where('created_at', '>', $this->start_date)->count();
         // Get landing page leads, grouped by day
         $landing_page->leads_data = $landing_page->getLeads($this->length);
         // Set dataset
         $chart->setLineBarDataSet($landing_page->leads_data, $landing_page->title, $i);
         // Push landing page dataset into campaign dataset
         $campaign->leads_data->push($chart->getDataSet());
         $landing_page->leads_graph = $chart->getLineBarChart();
     }
     $campaign->leads_graph = $chart->getLineBarChart($campaign->leads_data);
     // Get attribution data
     $campaign->attribution_data = \App\Attribution::getLeadCountSplit($campaign->landing_pages->lists('id'));
     $campaign->attribution = $chart->getPieChart($campaign->attribution_data);
     return view('campaigns.single')->with('has_admin_access', $campaign->isAdmin())->with('user', $this->user)->with('campaign', $campaign);
 }
Beispiel #5
0
 /**
  * Get lead count by attribution column
  * 
  * @param  Array $landing_pages
  * @param  String $column
  * @return Collection
  */
 private static function getLeadCount($landing_pages, $column)
 {
     $medium = Attribution::select(DB::raw("IFNULL({$column}, 'None') AS label"), DB::raw("COUNT('id') AS total"))->whereIn('landing_page_id', $landing_pages)->groupBy($column)->orderBy('total', 'desc')->lists('total', 'label');
     if (!$medium->isEmpty()) {
         return $medium;
     }
     return collect();
 }
 /**
  * Display the specified resource.
  *
  * @param  ShowRequest $request
  * @param  ChartContract $chart
  * @param  Integer $id
  * @return Response
  */
 public function show(ShowRequest $request, ChartContract $chart, $id)
 {
     $landing_page = Landing_Page::find($id);
     // Get leads, grouped by day
     $landing_page->leads_data = $landing_page->getLeads($this->length);
     // Get total lead count for date range
     $landing_page->leads_sum = $landing_page->leads()->where('created_at', '>', $this->start_date)->count();
     $chart->init($this->start_date, $this->end_date);
     $chart->setLineBarDataSet($landing_page->leads_data, $landing_page->title);
     $landing_page->leads_graph = $chart->getLineBarChart();
     // Get attribution data
     $landing_page->attribution_data = Attribution::getLeadCountSplit([$landing_page->id]);
     $landing_page->attribution = $chart->getPieChart($landing_page->attribution_data);
     return view('landing_pages.single')->with('has_admin_access', $landing_page->isAdmin())->with('user', $this->user)->with('landing_page', $landing_page);
 }