diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index 9b2dc01c64..e7573965ad 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -43,6 +43,8 @@ class BillController extends Controller Session::put('bills.create.url', URL::previous()); } Session::forget('bills.create.fromStore'); + Session::flash('gaEventCategory', 'bills'); + Session::flash('gaEventAction', 'create'); $subTitle = 'Create new bill'; return view('bills.create', compact('periods', 'subTitle')); @@ -57,6 +59,8 @@ class BillController extends Controller { // put previous url in session Session::put('bills.delete.url', URL::previous()); + Session::flash('gaEventCategory', 'bills'); + Session::flash('gaEventAction', 'delete'); $subTitle = 'Delete "' . e($bill->name) . '"'; return view('bills.delete', compact('bill', 'subTitle')); @@ -93,6 +97,8 @@ class BillController extends Controller Session::put('bills.edit.url', URL::previous()); } Session::forget('bills.edit.fromUpdate'); + Session::flash('gaEventCategory', 'bills'); + Session::flash('gaEventAction', 'edit'); return view('bills.edit', compact('subTitle', 'periods', 'bill')); } diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index a36079cd12..bd9364310d 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -64,6 +64,8 @@ class BudgetController extends Controller Session::put('budgets.create.url', URL::previous()); } Session::forget('budgets.create.fromStore'); + Session::flash('gaEventCategory', 'budgets'); + Session::flash('gaEventAction', 'create'); $subTitle = trans('firefly.create_new_budget'); return view('budgets.create', compact('subTitle')); @@ -80,6 +82,8 @@ class BudgetController extends Controller // put previous url in session Session::put('budgets.delete.url', URL::previous()); + Session::flash('gaEventCategory', 'budgets'); + Session::flash('gaEventAction', 'delete'); return view('budgets.delete', compact('budget', 'subTitle')); } @@ -99,6 +103,7 @@ class BudgetController extends Controller Session::flash('success', 'The budget "' . e($name) . '" was deleted.'); + return Redirect::to(Session::get('budgets.delete.url')); } @@ -116,6 +121,8 @@ class BudgetController extends Controller Session::put('budgets.edit.url', URL::previous()); } Session::forget('budgets.edit.fromUpdate'); + Session::flash('gaEventCategory', 'budgets'); + Session::flash('gaEventAction', 'edit'); return view('budgets.edit', compact('budget', 'subTitle')); diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index 7904a6adce..ba55ae289e 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -40,6 +40,8 @@ class CategoryController extends Controller Session::put('categories.create.url', URL::previous()); } Session::forget('categories.create.fromStore'); + Session::flash('gaEventCategory', 'categories'); + Session::flash('gaEventAction', 'create'); $subTitle = 'Create a new category'; return view('categories.create', compact('subTitle')); @@ -56,6 +58,8 @@ class CategoryController extends Controller // put previous url in session Session::put('categories.delete.url', URL::previous()); + Session::flash('gaEventCategory', 'categories'); + Session::flash('gaEventAction', 'delete'); return view('categories.delete', compact('category', 'subTitle')); } @@ -91,6 +95,8 @@ class CategoryController extends Controller Session::put('categories.edit.url', URL::previous()); } Session::forget('categories.edit.fromUpdate'); + Session::flash('gaEventCategory', 'categories'); + Session::flash('gaEventAction', 'edit'); return view('categories.edit', compact('category', 'subTitle')); diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php index 2ede528fa2..0e93e5ba35 100644 --- a/app/Http/Controllers/CurrencyController.php +++ b/app/Http/Controllers/CurrencyController.php @@ -45,6 +45,8 @@ class CurrencyController extends Controller Session::put('currency.create.url', URL::previous()); } Session::forget('currency.create.fromStore'); + Session::flash('gaEventCategory', 'currency'); + Session::flash('gaEventAction', 'create'); return view('currency.create', compact('subTitleIcon', 'subTitle')); } @@ -84,6 +86,8 @@ class CurrencyController extends Controller // put previous url in session Session::put('currency.delete.url', URL::previous()); + Session::flash('gaEventCategory', 'currency'); + Session::flash('gaEventAction', 'delete'); return view('currency.delete', compact('currency')); @@ -127,6 +131,8 @@ class CurrencyController extends Controller Session::put('currency.edit.url', URL::previous()); } Session::forget('currency.edit.fromUpdate'); + Session::flash('gaEventCategory', 'currency'); + Session::flash('gaEventAction', 'edit'); return view('currency.edit', compact('currency', 'subTitle', 'subTitleIcon')); diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index bd9b3043e0..16535314b6 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -72,6 +72,8 @@ class PiggyBankController extends Controller Session::put('piggy-banks.create.url', URL::previous()); } Session::forget('piggy-banks.create.fromStore'); + Session::flash('gaEventCategory', 'piggy-banks'); + Session::flash('gaEventAction', 'create'); return view('piggy-banks.create', compact('accounts', 'periods', 'subTitle', 'subTitleIcon')); } @@ -87,6 +89,8 @@ class PiggyBankController extends Controller // put previous url in session Session::put('piggy-banks.delete.url', URL::previous()); + Session::flash('gaEventCategory', 'piggy-banks'); + Session::flash('gaEventAction', 'delete'); return view('piggy-banks.delete', compact('piggyBank', 'subTitle')); } @@ -138,6 +142,8 @@ class PiggyBankController extends Controller 'remind_me' => intval($piggyBank->remind_me) == 1 && !is_null($piggyBank->reminder) ? true : false ]; Session::flash('preFilled', $preFilled); + Session::flash('gaEventCategory', 'piggy-banks'); + Session::flash('gaEventAction', 'edit'); // put previous url in session if not redirect from store (not "return_to_edit"). if (Session::get('piggy-banks.edit.fromUpdate') !== true) { diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 49f9b11f98..d776a58e1a 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -90,6 +90,10 @@ class ReportController extends Controller $balance = $this->helper->getBalanceReport($start, $end, $shared); $bills = $this->helper->getBillReport($start, $end, $shared); + Session::flash('gaEventCategory', 'report'); + Session::flash('gaEventAction', 'month'); + Session::flash('gaEventLabel', $start->format('F Y')); + return view( 'reports.month', @@ -133,6 +137,10 @@ class ReportController extends Controller $incomes = $this->helper->getIncomeReport($start, $end, $shared); $expenses = $this->helper->getExpenseReport($start, $end, $shared); + Session::flash('gaEventCategory', 'report'); + Session::flash('gaEventAction', 'year'); + Session::flash('gaEventLabel', $start->format('Y')); + return view( 'reports.year', diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 95e3fbdacd..5b572dd869 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -70,6 +70,8 @@ class TagController extends Controller Session::put('tags.create.url', URL::previous()); } Session::forget('tags.create.fromStore'); + Session::flash('gaEventCategory', 'tags'); + Session::flash('gaEventAction', 'create'); return view('tags.create', compact('subTitle', 'subTitleIcon')); } @@ -85,6 +87,8 @@ class TagController extends Controller // put previous url in session Session::put('tags.delete.url', URL::previous()); + Session::flash('gaEventCategory', 'tags'); + Session::flash('gaEventAction', 'delete'); return view('tags.delete', compact('tag', 'subTitle')); } @@ -141,6 +145,8 @@ class TagController extends Controller Session::put('tags.edit.url', URL::previous()); } Session::forget('tags.edit.fromUpdate'); + Session::flash('gaEventCategory', 'tags'); + Session::flash('gaEventAction', 'edit'); return view('tags.edit', compact('tag', 'subTitle', 'subTitleIcon', 'tagOptions')); } diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index c34cdfed54..4c88f3106b 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -62,6 +62,8 @@ class TransactionController extends Controller Session::put('transactions.create.url', URL::previous()); } Session::forget('transactions.create.fromStore'); + Session::flash('gaEventCategory', 'transactions'); + Session::flash('gaEventAction', 'create-' . $what); asort($piggies); @@ -83,6 +85,8 @@ class TransactionController extends Controller // put previous url in session Session::put('transactions.delete.url', URL::previous()); + Session::flash('gaEventCategory', 'transactions'); + Session::flash('gaEventAction', 'delete-' . $type); return view('transactions.delete', compact('journal', 'subTitle')); @@ -158,6 +162,8 @@ class TransactionController extends Controller $preFilled['account_to_id'] = $transactions[0]->account->id; Session::flash('preFilled', $preFilled); + Session::flash('gaEventCategory', 'transactions'); + Session::flash('gaEventAction', 'edit-' . $what); // put previous url in session if not redirect from store (not "return_to_edit"). if (Session::get('transactions.edit.fromUpdate') !== true) { diff --git a/resources/twig/layout/default.twig b/resources/twig/layout/default.twig index d6eb987e74..6f88f5131a 100644 --- a/resources/twig/layout/default.twig +++ b/resources/twig/layout/default.twig @@ -169,9 +169,12 @@ ga('send', 'pageview'); // send an event if relevant: - {% if Session.has('gaEventCategory') and Session.has('gaEventAction') %} + {% if Session.has('gaEventCategory') and Session.has('gaEventAction') and not Session.has('gaEventLabel') %} ga('send', 'event', '{{Session.get('gaEventCategory')}}', '{{Session.get('gaEventAction')}}'); {% endif %} + {% if Session.has('gaEventCategory') and Session.has('gaEventAction') and Session.has('gaEventLabel') %} + ga('send', 'event', '{{Session.get('gaEventCategory')}}', '{{Session.get('gaEventAction')}}','{{ Session.get('gaEventLabel') }}'); + {% endif %}