Skip to content

Firefly III: a personal finances manager

Add some GA events.

James Colefb2481ebaa0e
diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php
index af7c07bdd5..6b46ed2a03 100644
--- a/app/Http/Controllers/ProfileController.php
+++ b/app/Http/Controllers/ProfileController.php
@@ -109,6 +109,8 @@ class ProfileController extends Controller
// DELETE!
Auth::user()->delete();
Session::flush();
+ Session::flash('gaEventCategory', 'user');
+ Session::flash('gaEventAction', 'delete-account');
return Redirect::route('index');
}
diff --git a/resources/twig/layout/guest.twig b/resources/twig/layout/guest.twig
index 1d81e22141..90a026e44d 100644
--- a/resources/twig/layout/guest.twig
+++ b/resources/twig/layout/guest.twig
@@ -58,5 +58,28 @@
<script type="text/javascript" src="js/metisMenu.min.js"></script>
<script type="text/javascript" src="js/sb-admin-2.js"></script>
+<script>
+ (function (i, s, o, g, r, a, m) {
+ i['GoogleAnalyticsObject'] = r;
+ i[r] = i[r] || function () {
+ (i[r].q = i[r].q || []).push(arguments)
+ }, i[r].l = 1 * new Date();
+ a = s.createElement(o),
+ m = s.getElementsByTagName(o)[0];
+ a.async = 1;
+ a.src = g;
+ m.parentNode.insertBefore(a, m)
+ })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
+
+ ga('create', '{{ env('ANALYTICS_ID', 'XXX-XX-X') }}', 'auto');
+ ga('send', 'pageview');
+
+ // send an event if relevant:
+ {% if Session.has('gaEventCategory') and Session.has('gaEventAction') %}
+ ga('send', 'event', '{{Session.get('gaEventCategory')}}', '{{Session.get('gaEventAction')}}');
+ {% endif %}
+
+</script>
+
</body>
</html>