Skip to content

Commit

Permalink
Add new scroll tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
andysellick committed Jan 6, 2022
1 parent 57ae616 commit e0ca197
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/views/content_items/answer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
<%= machine_readable_metadata(
schema: :faq
) %>

<%
scroll_track_headings_paths = [
"/wood-packaging-import-export",
]
scroll_track_percent_paths = [
"/get-coronavirus-test",
]
%>
<% if scroll_track_headings_paths.include?(@content_item.base_path) %>
<meta name="govuk:scroll-tracker" content="" data-module="auto-scroll-tracker" data-track-type="headings"/>
<% elsif scroll_track_percent_paths.include?(@content_item.base_path) %>
<meta name="govuk:scroll-tracker" content="" data-module="auto-scroll-tracker"/>
<% end %>
<% end %>

<%= render 'content_items/body_with_related_links' %>
24 changes: 24 additions & 0 deletions app/views/content_items/detailed_guide.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@
<%= machine_readable_metadata(
schema: :faq
) %>

<%
scroll_track_headings_paths = [
"/guidance/universal-credit-how-it-helps-you-into-work",
"/guidance/returning-to-the-uk",
"/guidance/foreign-travel-insurance",
"/guidance/living-in-france",
"/guidance/healthcare-for-eu-and-efta-citizens-visiting-the-uk",
"/guidance/guidance-for-suppliers-of-cattle-sheep-and-goat-ear-tags",
"/guidance/ecmt-international-road-haulage-permits",
"/guidance/travel-abroad-from-england-during-coronavirus-covid-19",
"/guidance/travel-to-england-from-another-country-during-coronavirus-covid-19",
]
scroll_track_percent_paths = [
"/guidance/brexit-guidance-for-businesses",
"/guidance/brexit-guidance-for-individuals-and-families",
"/guidance/import-and-export-goods-using-preference-agreements",
]
%>
<% if scroll_track_headings_paths.include?(@content_item.base_path) %>
<meta name="govuk:scroll-tracker" content="" data-module="auto-scroll-tracker" data-track-type="headings"/>
<% elsif scroll_track_percent_paths.include?(@content_item.base_path) %>
<meta name="govuk:scroll-tracker" content="" data-module="auto-scroll-tracker"/>
<% end %>
<% end %>

<%= render 'shared/email_subscribe_unsubscribe_flash' %>
Expand Down
15 changes: 15 additions & 0 deletions app/views/content_items/guide.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@
canonical_url: @content_item.canonical_url,
body: @content_item.has_parts? ? @content_item.current_part_body : nil
) %>

<%
scroll_track_headings_paths = [
"/council-housing",
"/driving-abroad",
"/get-a-passport-urgently",
"/driving-abroad/international-driving-permit",
"/taking-goods-out-uk-temporarily/get-an-ata-carnet",
]

full_url = [@content_item.base_path, @content_item.part_slug].compact.join('/')
%>
<% if scroll_track_headings_paths.include?(full_url) %>
<meta name="govuk:scroll-tracker" content="" data-module="auto-scroll-tracker" data-track-type="headings"/>
<% end %>
<% end %>

<% unless @content_item.requesting_a_part? %>
Expand Down
10 changes: 10 additions & 0 deletions app/views/content_items/html_publication.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
<%= machine_readable_metadata(
schema: :html_publication
) %>

<%
scroll_track_headings_paths = [
"/government/publications/the-essential-trustee-what-you-need-to-know-cc3/the-essential-trustee-what-you-need-to-know-what-you-need-to-do",
"/government/publications/spring-budget-2017-documents/spring-budget-2017",
]
%>
<% if scroll_track_headings_paths.include?(@content_item.base_path) %>
<meta name="govuk:scroll-tracker" content="" data-module="auto-scroll-tracker" data-track-type="headings"/>
<% end %>
<% end %>

<%
Expand Down

0 comments on commit e0ca197

Please sign in to comment.