Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove GA4 callout tracking from the govspeak component #3946

Merged
merged 1 commit into from Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@
## Unreleased

* Improve test coverage of contextual breadcrumb logic ([PR #3944](https://github.com/alphagov/govuk_publishing_components/pull/3944) and [PR #3945](https://github.com/alphagov/govuk_publishing_components/pull/3945))
* Remove GA4 callout tracking from the govspeak component ([PR #3946](https://github.com/alphagov/govuk_publishing_components/pull/3946))

## 37.9.1

Expand Down
Expand Up @@ -10,20 +10,9 @@
classes << "disable-youtube" if disable_youtube_expansions
classes << "gem-c-govspeak--inverse" if inverse

disable_ga4 ||= false

data_modules = "govspeak"
data_modules << " ga4-link-tracker" unless disable_ga4
data_attributes = { module: data_modules }

unless disable_ga4
data_attributes.merge!({
ga4_track_links_only: "",
ga4_limit_to_element_class: "call-to-action, info-notice, help-notice, advisory",
ga4_link: { "event_name": "navigation", "type": "callout" }.to_json,
})
end

%>

<%= tag.div(class: "gem-c-govspeak govuk-govspeak " + classes.join(" "), data: data_attributes) do %>
Expand Down
Expand Up @@ -30,7 +30,6 @@
if description_govspeak
govspeak_data_attributes = {
content: description_govspeak,
disable_ga4: true # Keep the govspeak component GA4 tracking disabled, otherwise tracking will be duplicated when tracking is enabled on this component.
}
end

Expand Down
Expand Up @@ -914,12 +914,3 @@ examples:
<p>Deforested area. Credit: Blue Ventures-Garth Cripps</p>
</figcaption>
</figure>
without_ga4_tracking:
description: |
Disables GA4 tracking on the component. Tracking is enabled by default. This adds a data module and data-attributes with JSON data. See the [ga4-link-tracker documentation](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/ga4-link-tracker.md) for more information.
data:
block: |
<p>
<a href='https://www.gov.uk'>Hello World</a>
</p>
disable_ga4: true
23 changes: 0 additions & 23 deletions spec/components/govspeak_spec.rb
Expand Up @@ -46,27 +46,4 @@ def component_name

expect(rendered).to include("content-via-block")
end

it "adds GA4 tracking" do
render_component(
content: "<h1>content</h1>".html_safe,
)

assert_select ".gem-c-govspeak[data-module='govspeak ga4-link-tracker']"
assert_select ".gem-c-govspeak[data-ga4-track-links-only]"
assert_select ".gem-c-govspeak[data-ga4-limit-to-element-class='call-to-action, info-notice, help-notice, advisory']"
assert_select '.gem-c-govspeak[data-ga4-link="{\"event_name\":\"navigation\",\"type\":\"callout\"}"]'
end

it "can disable GA4 tracking" do
render_component(
content: "<h1>content</h1>".html_safe,
disable_ga4: true,
)

assert_no_selector ".gem-c-govspeak[data-module='govspeak ga4-link-tracker']"
assert_no_selector ".gem-c-govspeak[data-ga4-track-links-only]"
assert_no_selector ".gem-c-govspeak[data-ga4-limit-to-element-class]"
assert_no_selector ".gem-c-govspeak[data-ga4-link]"
end
end