Skip to content

Commit a6e81c7

Browse files
committed
Add some tracking to the description link
1 parent 76228b3 commit a6e81c7

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

app/views/content_items/detailed_guide.html.erb

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,17 @@
1515
<% if brexit_link %>
1616
<div class="govuk-body-l govuk-!-margin-bottom-7">
1717
<p class="govuk-body">
18-
<%= I18n.t("brexit.heading_prefix") %> <%= link_to brexit_link[:text], brexit_link[:path] %>.
18+
<%= I18n.t("brexit.heading_prefix") %>
19+
<%= link_to(
20+
brexit_link[:text],
21+
brexit_link[:path],
22+
class: "govuk-link",
23+
data: {
24+
track_action: brexit_link[:path],
25+
track_category: brexit_link[:track_category],
26+
track_label: brexit_link[:text],
27+
module: 'gem-track-click',
28+
}) %>.
1929
</p>
2030
</div>
2131
<% else %>

test/integration/detailed_guide_test.rb

+10-1
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,22 @@ class DetailedGuideTest < ActionDispatch::IntegrationTest
112112
link_text = "Brexit guidance for businesses"
113113
assert page.has_link?(link_text, href: ContentItem::BrexitHubPage::BREXIT_BUSINESS_PAGE_PATH)
114114

115-
# adds GA tracking to the links
115+
# adds GA tracking to the li links
116116
track_action = find_link("Foreign travel advice")["data-track-action"]
117117
track_category = find_link("Foreign travel advice")["data-track-category"]
118118
track_label = find_link("Foreign travel advice")["data-track-label"]
119119

120120
assert_equal "/foreign-travel-advice", track_action
121121
assert_equal "brexit-citizen-page", track_category
122122
assert_equal "Travel to the EU", track_label
123+
124+
# adds GA tracking to the description field links
125+
track_action = find_link("Brexit guidance for businesses")["data-track-action"]
126+
track_category = find_link("Brexit guidance for businesses")["data-track-category"]
127+
track_label = find_link("Brexit guidance for businesses")["data-track-label"]
128+
129+
assert_equal ContentItem::BrexitHubPage::BREXIT_BUSINESS_PAGE_PATH, track_action
130+
assert_equal "brexit-citizen-page", track_category
131+
assert_equal "Brexit guidance for businesses", track_label
123132
end
124133
end

0 commit comments

Comments
 (0)