diff --git a/app/assets/javascripts/modules/global-bar.js b/app/assets/javascripts/modules/global-bar.js index 5161afc3d..ed6a6800d 100644 --- a/app/assets/javascripts/modules/global-bar.js +++ b/app/assets/javascripts/modules/global-bar.js @@ -13,12 +13,20 @@ count = viewCount(); $el.on('click', '.dismiss', hide); + $el.on('click', '.js-call-to-action', handleCallToActionClick); + if ($el.is(':visible')) { incrementViewCount(count); track('Viewed'); } + function handleCallToActionClick () { + var $link = $(this); + var url = $link.attr('href') + track(url); + } + function hide(evt) { $el.hide(); GOVUK.setCookie(GLOBAL_BAR_SEEN_COOKIE, 999, {days: 84}); diff --git a/app/views/notifications/_global_bar.html.erb b/app/views/notifications/_global_bar.html.erb index 989cc3207..5e5cdbd7f 100644 --- a/app/views/notifications/_global_bar.html.erb +++ b/app/views/notifications/_global_bar.html.erb @@ -17,7 +17,12 @@

<%= title %> <%= information %> - <%= link_to(link_text, link_href, rel: "external noreferrer") %> + <%= link_to( + link_text, + link_href, + rel: "external noreferrer", + class: "js-call-to-action" + ) %>