aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2014-04-09 12:45:19 +0100
committerStruan Donald <struan@exo.org.uk>2014-04-09 12:45:19 +0100
commit33bf702edceb459954b5b6a3ef41e6cddd6756a3 (patch)
tree22b01f7ca49a7b41914b0ea97c0a57b1dab5cb70
parentb82228ce014cc87866d976eeb3ce6e454e87c336 (diff)
Fire a google analytics event on report completion
At the moment it's hard to use google analytics to track when someone has completed a report due to the various redirects which can occur too quickly for the analytics javascript to fire. So now we fire an event if we've set a flash value. This also allows us to track how they created the report.
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm1
-rw-r--r--perllib/FixMyStreet/App/Controller/Tokens.pm1
-rw-r--r--templates/web/default/report/extra_analytics.html0
-rw-r--r--templates/web/default/tokens/confirm_problem.html1
-rw-r--r--templates/web/fixmystreet/report/display.html1
-rw-r--r--templates/web/fixmystreet/report/extra_analytics.html8
6 files changed, 12 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index bf9f171be..761215344 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -1155,6 +1155,7 @@ sub redirect_or_confirm_creation : Private {
$report_uri = $c->cobrand->base_url_for_report( $report ) . $report->url;
}
$c->log->info($report->user->id . ' was logged in, redirecting to /report/' . $report->id);
+ $c->flash->{created_report} = 'loggedin';
$c->res->redirect($report_uri);
$c->detach;
}
diff --git a/perllib/FixMyStreet/App/Controller/Tokens.pm b/perllib/FixMyStreet/App/Controller/Tokens.pm
index 5e536afa3..19130e25f 100644
--- a/perllib/FixMyStreet/App/Controller/Tokens.pm
+++ b/perllib/FixMyStreet/App/Controller/Tokens.pm
@@ -102,6 +102,7 @@ sub confirm_problem : Path('/P') {
$c->res->redirect($report_uri);
}
+ $c->flash->{created_report} = 'fromemail';
return 1;
}
diff --git a/templates/web/default/report/extra_analytics.html b/templates/web/default/report/extra_analytics.html
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/templates/web/default/report/extra_analytics.html
diff --git a/templates/web/default/tokens/confirm_problem.html b/templates/web/default/tokens/confirm_problem.html
index 723d515e1..51b459925 100644
--- a/templates/web/default/tokens/confirm_problem.html
+++ b/templates/web/default/tokens/confirm_problem.html
@@ -28,4 +28,5 @@ You can <a href="[% c.cobrand.base_url_for_report( problem ) %][% problem.url %]
[% display_crosssell_advert( problem.user.email, problem.name ) %]
+[% INCLUDE 'report/extra_analytics.html' %]
[% INCLUDE 'footer.html' %]
diff --git a/templates/web/fixmystreet/report/display.html b/templates/web/fixmystreet/report/display.html
index b75ef92bc..2c65ca104 100644
--- a/templates/web/fixmystreet/report/display.html
+++ b/templates/web/fixmystreet/report/display.html
@@ -23,6 +23,7 @@
[% INCLUDE 'report/banner.html' %]
[% INCLUDE 'report/_main.html' %]
+[% INCLUDE 'report/extra_analytics.html' %]
[% TRY %][% INCLUDE 'report/_message_manager.html' %][% CATCH file %][% END %]
<div class="shadow-wrap">
diff --git a/templates/web/fixmystreet/report/extra_analytics.html b/templates/web/fixmystreet/report/extra_analytics.html
new file mode 100644
index 000000000..4a993cc2d
--- /dev/null
+++ b/templates/web/fixmystreet/report/extra_analytics.html
@@ -0,0 +1,8 @@
+[% IF c.flash.created_report %]
+<script type="text/javascript">
+ var cobrand = $('meta[name="cobrand"]').attr('content');
+ if ( typeof ga !== 'undefined' && cobrand == 'fixmystreet' ) {
+ ga('send', 'event', 'report', 'completed', '[% c.flash.created_report %]' );
+ }
+</script>
+[% END %]