<%= render "govuk_publishing_components/components/heading",
- text: t('supergroups.topics'),
- heading_level: 2,
- font_size: 19 %>
+ text: t('supergroups.topics'),
+ heading_level: 2,
+ font_size: 19
+ %>
- <% tagged_taxons.each do |tagged_taxon| %>
+ <% tagged_taxons.each_with_index do |tagged_taxon, index| %>
-
- <%= link_to tagged_taxon[:taxon_name], tagged_taxon[:taxon_link] %>
+ <%= link_to(
+ tagged_taxon[:taxon_name],
+ tagged_taxon[:taxon_link],
+ data: {
+ "track-category": "relatedTaxonomyLinkClicked",
+ "track-action": "1.#{index} Topics",
+ "track-label": tagged_taxon[:taxon_link],
+ "track-options": {
+ dimension29: tagged_taxon[:taxon_name]
+ }
+ }
+ ) %>
<% end %>
@@ -22,9 +34,20 @@
heading_level: 2,
font_size: 19 %>
- <% related_collections.each do |base_path, title| %>
+ <% related_collections.each_with_index do |collection, index| %>
-
- <%= link_to title, base_path %>
+ <%= link_to(
+ collection[1],
+ collection[0],
+ data: {
+ "track-category": "relatedTaxonomyLinkClicked",
+ "track-action": "2.#{index} Collections",
+ "track-label": collection[0],
+ "track-options": {
+ dimension29: collection[1]
+ }
+ }
+ ) %>
<% end %>
diff --git a/test/integration/content_pages_navigation_test.rb b/test/integration/content_pages_navigation_test.rb
index bdf4bb4b2..5e65ae77d 100644
--- a/test/integration/content_pages_navigation_test.rb
+++ b/test/integration/content_pages_navigation_test.rb
@@ -337,7 +337,20 @@ def setup
end
end
- test "ContentPagesNav variant B shows home breadcrumb when a page belongs to a two topics and a step by step" do
+ test "ContentPagesNav variant B has tracking on banner links for single topic and a step by step" do
+ stub_rummager
+ setup_variant_b
+
+ setup_and_visit_content_item_with_taxons('guide-with-step-navs', SINGLE_TAXON)
+
+ within('.taxonomy-navigation__banner') do
+ assert page.has_css?('a[data-track-category="relatedTaxonomyLinkClicked"]', text: 'Learn to drive a car: step by step')
+ assert page.has_css?('a[data-track-action="1.1 Step by Step"]', text: 'Learn to drive a car: step by step')
+ assert page.has_css?('a[data-track-label="/learn-to-drive-a-car"]')
+ end
+ end
+
+ test "ContentPagesNav variant B shows home breadcrumb when a page belongs to two topics and a step by step" do
stub_rummager
setup_variant_b
@@ -365,6 +378,23 @@ def setup
end
end
+ test "ContentPagesNav variant B has tracking on banner links for two topics and a step by step" do
+ stub_rummager
+ setup_variant_b
+
+ setup_and_visit_content_item_with_taxons('guide-with-step-navs', TWO_TAXONS)
+
+ within('.taxonomy-navigation__banner') do
+ assert page.has_css?('a[data-track-category="relatedTaxonomyLinkClicked"]', text: 'Learn to drive a car: step by step')
+ assert page.has_css?('a[data-track-action="1.1 Step by Step"]', text: 'Learn to drive a car: step by step')
+ assert page.has_css?('a[data-track-label="/learn-to-drive-a-car"]')
+
+ assert page.has_css?('a[data-track-category="relatedTaxonomyLinkClicked"]', text: 'Becoming an apprentice')
+ assert page.has_css?('a[data-track-action="1.1 Taxon"]', text: 'Becoming an apprentice')
+ assert page.has_css?('a[data-track-label="/education/becoming-an-apprentice"]')
+ end
+ end
+
test "ContentPagesNav variant B shows home breadcrumb when a page belongs to more than two topics and a step by step" do
stub_rummager
setup_variant_b
diff --git a/test/integration/content_pages_related_navigation_test.rb b/test/integration/content_pages_related_navigation_test.rb
index 3591b9fb8..4d9b063bf 100644
--- a/test/integration/content_pages_related_navigation_test.rb
+++ b/test/integration/content_pages_related_navigation_test.rb
@@ -16,6 +16,21 @@ def setup
assert page.has_css?('.gem-c-related-navigation__sub-heading', text: 'Collection')
end
+ test "ContentPagesNav variant B shows tagged taxons in the taxonomy navigation" do
+ stub_rummager
+ setup_variant_b
+
+ setup_and_visit_content_item_with_taxons('case_study', SINGLE_TAXON)
+
+ within '.taxonomy-navigation' do
+ assert page.has_css?('.gem-c-heading', text: 'Topics')
+ assert page.has_css?('.taxonomy-navigation__list-item a', text: 'Becoming an apprentice')
+ assert page.has_css?('.taxonomy-navigation__list-item a[data-track-category="relatedTaxonomyLinkClicked"]', text: 'Becoming an apprentice')
+ assert page.has_css?('.taxonomy-navigation__list-item a[data-track-action="1.0 Topics"]', text: 'Becoming an apprentice')
+ assert page.has_css?('.taxonomy-navigation__list-item a[data-track-label="/education/becoming-an-apprentice"]')
+ end
+ end
+
test "ContentPagesNav variant B shows related collections in the taxonomy navigation" do
stub_rummager
setup_variant_b
@@ -24,6 +39,10 @@ def setup
within '.taxonomy-navigation' do
assert page.has_css?('.gem-c-heading', text: 'Collections')
+ assert page.has_css?('.taxonomy-navigation__list-item a', text: 'Work Programme real life stories')
+ assert page.has_css?('.taxonomy-navigation__list-item a[data-track-category="relatedTaxonomyLinkClicked"]', text: 'Work Programme real life stories')
+ assert page.has_css?('.taxonomy-navigation__list-item a[data-track-action="2.0 Collections"]', text: 'Work Programme real life stories')
+ assert page.has_css?('.taxonomy-navigation__list-item a[data-track-label="/government/collections/work-programme-real-life-stories"]')
end
end