diff options
author | Matthew Somerville <matthew@mysociety.org> | 2014-07-08 14:21:10 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2014-07-08 17:59:17 +0100 |
commit | 5559dc28c62bcccb320b784e3e568ec0b92c7769 (patch) | |
tree | f7e5ecbfca26d2df6bac7f7e6d0c659b29b11102 | |
parent | eed7e093af42c443f81c22ad31de3baf4f8e9fec (diff) |
Update GA code to use ecommerce ping.
-rw-r--r-- | t/app/controller/report_new.t | 10 | ||||
-rw-r--r-- | templates/web/fixmystreet.com/tracking_code.html | 14 |
2 files changed, 12 insertions, 12 deletions
diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index e3dc46c64..d687b4903 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -1534,7 +1534,7 @@ subtest "extra google analytics code displayed on logged in problem creation" => # check that we got redirected to /report/ is $mech->uri->path, "/report/" . $report->id, "redirected to report page"; - $mech->content_contains( "extra = '?created_report", 'extra google code present' ); + $mech->content_contains( "'id': 'report/" . $report->id . "'", 'extra google code present' ); # cleanup $mech->delete_user($user); @@ -1584,12 +1584,16 @@ subtest "extra google analytics code displayed on email confirmation problem cre # confirm token in order to update the user details $mech->get_ok($url); - $mech->content_contains( "extra = '?created_report", 'extra google code present' ); - + # find the report my $user = FixMyStreet::App->model('DB::User') ->find( { email => 'firstlast@example.com' } ); + my $report = $user->problems->first; + ok $report, "Found the report"; + + $mech->content_contains( "'id': 'report/" . $report->id . "'", 'extra google code present' ); + $user->problems->delete; $user->alerts->delete; $user->delete; diff --git a/templates/web/fixmystreet.com/tracking_code.html b/templates/web/fixmystreet.com/tracking_code.html index 0453e1a22..1dd176189 100644 --- a/templates/web/fixmystreet.com/tracking_code.html +++ b/templates/web/fixmystreet.com/tracking_code.html @@ -8,16 +8,12 @@ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) ga('create', 'UA-660910-4', {'cookieDomain': '.fixmystreet.com'}); ga('set', 'anonymizeIp', true); [% IF created_report %] -ga(function(tracker) { - var page = tracker.get('location'); - var extra = ''; - if ( page.indexOf('?') != -1 ) { - extra = '&created_report=1'; - } else { - extra = '?created_report=1'; - } - tracker.set('location', page + extra); +ga('require', 'ecommerce'); +ga('ecommerce:addItem', { + 'id': 'report/[% problem.id %]', + 'name': 'Report' }); +ga('ecommerce:send'); [% END %] ga('send', 'pageview'); |