Skip to content

Commit

Permalink
Merge pull request #1585 from alphagov/add-tracking-for-call-to-actio…
Browse files Browse the repository at this point in the history
…n-banner-link

Add tracking event when link in banner is pressed
  • Loading branch information
NickColley authored Dec 6, 2018
2 parents f62738d + 1ec50a5 commit bb14ffa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/assets/javascripts/modules/global-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
7 changes: 6 additions & 1 deletion app/views/notifications/_global_bar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
<p class="global-bar-message">
<span class="global-bar-title"><%= title %></span>
<%= information %>
<%= link_to(link_text, link_href, rel: "external noreferrer") %>
<%= link_to(
link_text,
link_href,
rel: "external noreferrer",
class: "js-call-to-action"
) %>
</p>
<a href="#hide-message"
class="dismiss"
Expand Down

0 comments on commit bb14ffa

Please sign in to comment.