From 2e409939f0da121a8c71a630ab0ab2014df9718e Mon Sep 17 00:00:00 2001 From: AshGDS <8880610+AshGDS@users.noreply.github.com> Date: Tue, 20 Feb 2024 15:57:54 +0000 Subject: [PATCH] Add GA4 tracking to webchat available link --- app/views/shared/_webchat.html.erb | 10 +++++++++- test/integration/contact_test.rb | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/views/shared/_webchat.html.erb b/app/views/shared/_webchat.html.erb index 01673eb28..4c86cfdfc 100644 --- a/app/views/shared/_webchat.html.erb +++ b/app/views/shared/_webchat.html.erb @@ -20,7 +20,15 @@ <%= t("shared.webchat.available") %> - <%= t("shared.webchat.speak_to_adviser") %>. + "> + <%= t("shared.webchat.speak_to_adviser") %> + . <% end %> diff --git a/test/integration/contact_test.rb b/test/integration/contact_test.rb index 80c35364c..7ba14d7aa 100644 --- a/test/integration/contact_test.rb +++ b/test/integration/contact_test.rb @@ -81,4 +81,11 @@ class ContactTest < ActionDispatch::IntegrationTest # reset back to default driver Capybara.use_default_driver end + + test "has GA4 tracking on the webchat available link" do + setup_and_visit_content_item("contact", { base_path: "/government/organisations/hm-passport-office/contact/hm-passport-office-webchat", details: { "more_info_webchat": "

Some HTML

\n" } }) + + assert_selector ".js-webchat-advisers-available a[data-module=ga4-link-tracker]" + assert_selector ".js-webchat-advisers-available a[data-ga4-link='{\"event_name\":\"navigation\",\"type\":\"webchat\",\"text\":\"Speak to an adviser now\"}']" + end end