Track campaign fields with company

This commit is contained in:
Hillel Coren 2016-11-06 14:16:18 +02:00
parent 0a20460242
commit 26f4a84897
3 changed files with 12 additions and 8 deletions

View File

@ -38,7 +38,7 @@ class HomeController extends BaseController
public function showIndex() public function showIndex()
{ {
Session::reflash(); Session::reflash();
if (!Utils::isNinja() && (!Utils::isDatabaseSetup() || Account::count() == 0)) { if (!Utils::isNinja() && (!Utils::isDatabaseSetup() || Account::count() == 0)) {
return Redirect::to('/setup'); return Redirect::to('/setup');
} elseif (Auth::check()) { } elseif (Auth::check()) {
@ -76,10 +76,8 @@ class HomeController extends BaseController
} }
// Track the referral/campaign code // Track the referral/campaign code
foreach (['rc', 'utm_campaign'] as $code) { if (Input::has('rc')) {
if (Input::has($code)) { Session::set(SESSION_REFERRAL_CODE, Input::get('rc'));
Session::set(SESSION_REFERRAL_CODE, Input::get($code));
}
} }
if (Auth::check()) { if (Auth::check()) {
@ -115,7 +113,7 @@ class HomeController extends BaseController
$user->save(); $user->save();
} }
} }
Session::forget('news_feed_message'); Session::forget('news_feed_message');
return 'success'; return 'success';

View File

@ -2,6 +2,7 @@
use Auth; use Auth;
use Request; use Request;
use Input;
use Session; use Session;
use Utils; use Utils;
use URL; use URL;
@ -27,6 +28,11 @@ class AccountRepository
public function create($firstName = '', $lastName = '', $email = '', $password = '') public function create($firstName = '', $lastName = '', $email = '', $password = '')
{ {
$company = new Company(); $company = new Company();
$company->utm_source = Input::get('utm_source');
$company->utm_medium = Input::get('utm_medium');
$company->utm_campaign = Input::get('utm_campaign');
$company->utm_term = Input::get('utm_term');
$company->utm_content = Input::get('utm_content');
$company->save(); $company->save();
$account = new Account(); $account = new Account();

View File

@ -2,7 +2,7 @@
@section('body') @section('body')
{!! Form::open(array('url' => 'get_started', 'id' => 'startForm')) !!} {!! Form::open(array('url' => 'get_started?' . request()->getQueryString(), 'id' => 'startForm')) !!}
{!! Form::hidden('guest_key') !!} {!! Form::hidden('guest_key') !!}
{!! Form::hidden('sign_up', Input::get('sign_up')) !!} {!! Form::hidden('sign_up', Input::get('sign_up')) !!}
{!! Form::hidden('redirect_to', Input::get('redirect_to')) !!} {!! Form::hidden('redirect_to', Input::get('redirect_to')) !!}
@ -34,4 +34,4 @@
} }
</script> </script>
@stop @stop