Skip to content

Commit

Permalink
Custom meta tag to track spelling suggestions
Browse files Browse the repository at this point in the history
For finders where we show spelling suggestions, we want to
track their page view impressions.
First part of the work is in static
alphagov/static#1927

Here we insert the meta tag into the document head for analytics script
to pick up.
  • Loading branch information
kr8n3r committed Nov 4, 2019
1 parent ae3c6fc commit 7270f13
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/views/finders/_spelling_suggestion.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<% # we want an empty string if there are no suggestions on page load %>
<% _spelling_suggestion = '' %>
<% if @spelling_suggestion_presenter.suggestions.any? %>
<p class="govuk-body">Did you mean
<% @spelling_suggestion_presenter.suggestions.each do |suggestion| %>
<%= link_to suggestion[:keywords], suggestion[:link],
class: "govuk-link govuk-!-font-weight-bold",
:data => suggestion[:data_attributes]
%>
<% _spelling_suggestion << suggestion[:keywords] %>
<% end %>
</p>
<% end %>
<% end %>
<% content_for :head do %>
<meta name="govuk:spelling-suggestion" content="<%= _spelling_suggestion %>">
<% end %>

0 comments on commit 7270f13

Please sign in to comment.