Skip to content

Commit

Permalink
Merge pull request #3946 from alphagov/ga4-remove-callout-tracking-again
Browse files Browse the repository at this point in the history
Remove GA4 callout tracking from the govspeak component
  • Loading branch information
AshGDS committed Mar 22, 2024
2 parents 160e835 + 09c7915 commit 1c7402e
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 44 deletions.
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

0 comments on commit 1c7402e

Please sign in to comment.