Skip to content

Commit 570621a

Browse files
committed
Add GA tracking to external campaign links
1 parent e3cc4b9 commit 570621a

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

app/controllers/concerns/contextual_comms_ab_testable.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,10 @@ def campaign_name
8484
end
8585

8686
def campaign_link
87-
CAMPAIGN_DATA[campaign_name][:link]
87+
CAMPAIGN_DATA[campaign_name][:link] +
88+
"?utm_source=#{content_item_path}" +
89+
"&utm_content=#{contextual_comms_test_variant.variant_name}" +
90+
"&utm_campaign=ukgov-promo&utm_medium=referral"
8891
end
8992

9093
def campaign_title

test/controllers/contextual_comms_ab_test_controller_test.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ class ContentItemsControllerTest < ActionController::TestCase
1010
govuk_base_path: "/career-skills-and-training",
1111
title: "Get In Go Far",
1212
description: "Search thousands of apprenticeships from great companies, with more added every day.",
13-
href: "<a href=\"https://www.getingofar.gov.uk/\">",
13+
href: "https://www.getingofar.gov.uk/",
1414
},
1515
eating: {
1616
govuk_base_path: "/free-school-transport",
1717
title: "How healthy is your food?",
1818
description: "Find out more about calories, the benefits of eating well and simple ways you can make a change.",
19-
href: "<a href=\"https://www.nhs.uk/oneyou/eating\">",
19+
href: "https://www.nhs.uk/oneyou/eating",
2020
},
2121
check_your_pay: {
2222
govuk_base_path: "/pay-and-work-rights",
2323
title: "Check Your Pay",
2424
description: "Are you being underpaid? Find out if your employer is giving you less than the legal minimum.",
25-
href: "<a href=\"https://checkyourpay.campaign.gov.uk\">",
25+
href: "https://checkyourpay.campaign.gov.uk",
2626
},
2727
your_pension: {
2828
govuk_base_path: "/armed-forces-pension-calculator",
2929
title: "Get to know your state pension",
3030
description: "Get an online forecast to tell you how much you might get, and the earliest you can claim it.",
31-
href: "<a href=\"https://www.yourpension.gov.uk/\">"
31+
href: "https://www.yourpension.gov.uk/",
3232
}
3333
}.freeze
3434

@@ -61,7 +61,7 @@ class ContentItemsControllerTest < ActionController::TestCase
6161
assert_match("blue-box-campaign", response.body)
6262
assert_match(value[:title], response.body)
6363
assert_match(value[:description], response.body)
64-
assert_match(value[:href], response.body)
64+
assert_select("a:match('href', ?)", value[:href])
6565
end
6666
end
6767
end
@@ -80,7 +80,7 @@ class ContentItemsControllerTest < ActionController::TestCase
8080
assert_match("native-campaign", response.body)
8181
assert_match(value[:title], response.body)
8282
assert_match(value[:description], response.body)
83-
assert_match(value[:href], response.body)
83+
assert_select("a:match('href', ?)", value[:href])
8484
end
8585
end
8686
end

0 commit comments

Comments
 (0)