Skip to content

Commit

Permalink
Remove misc UA references
Browse files Browse the repository at this point in the history
  • Loading branch information
andysellick committed Jul 30, 2024
1 parent 8e0381e commit b15181f
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,10 @@
for (var i = 0; i < $youtubeLinks.length; ++i) {
var $link = $youtubeLinks[i]
var href = $link.getAttribute('href')
var hasTracking = $link.hasAttribute('data-youtube-player-analytics')
var options = {
link: $link
}

if (hasTracking) {
options.tracking = {
hasTracking: hasTracking,
category: $link.getAttribute('data-youtube-player-analytics-category')
}
}

if (href.indexOf('/live_stream') >= 0) {
var channelId = YoutubeLinkEnhancement.parseLivestream(href)

Expand Down Expand Up @@ -122,7 +114,6 @@
},
onStateChange: function (event) {
var eventData = event.data
var eventTarget = event.target
var states = {
/* eslint-disable quote-props */
'-1': 'VideoUnstarted',
Expand All @@ -133,17 +124,6 @@
'5': 'VideoCued'
/* eslint-enable */
}
if (states[eventData] && options.tracking && options.tracking.hasTracking &&
window.GOVUK.analytics && window.GOVUK.analytics.trackEvent) {
var tracking = {
category: options.tracking.category,
action: states[eventData],
label: { transport: 'beacon', label: eventTarget.getVideoData && eventTarget.getVideoData().title }
}

window.GOVUK.analytics.trackEvent(tracking.category, tracking.action, tracking.label)
}

if (window.GOVUK.analyticsGa4.analyticsModules.VideoTracker) {
window.GOVUK.analyticsGa4.analyticsModules.VideoTracker.trackVideo(event, states[eventData])
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<%= tag.footer class: classes, role: "contentinfo", 'data-module': "ga4-link-tracker" do %>
<div class="govuk-width-container">
<% if navigation.any? %>
<div class="govuk-footer__navigation" data-module="gem-track-click" data-track-links-only>
<div class="govuk-footer__navigation">
<% navigation.each_with_index do |section, ga4_section_index| %>
<% if section[:items] %>
<%
Expand Down Expand Up @@ -69,7 +69,7 @@
<div class="govuk-footer__meta-item govuk-footer__meta-item--grow">
<% if meta.any? %>
<h2 class="govuk-visually-hidden"><%= t("components.layout_footer.support_links") %></h2>
<ul class="govuk-footer__inline-list govuk-!-display-none-print" data-module="gem-track-click" data-track-links-only>
<ul class="govuk-footer__inline-list govuk-!-display-none-print">
<% index_total = meta[:items].length %>
<% meta[:items].each_with_index do |item, index| %>
<li class="govuk-footer__inline-list-item">
Expand Down Expand Up @@ -100,12 +100,6 @@
<% # this is to avoid having hardcoded data attributes in locale files %>
<span
class="govuk-footer__licence-description"
data-module="gem-track-click"
data-track-action="copyrightLink"
data-track-category="footerClicked"
data-track-label="https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/"
data-track-options='{"dimension29": "Open Government Licence v3.0"}'
data-track-links-only
data-ga4-track-links-only
data-ga4-link="<%= {
"event_name": "navigation",
Expand All @@ -124,12 +118,6 @@
<% # this is to avoid having hardcoded data attributes in locale files %>
<div
class="govuk-footer__meta-item"
data-module="gem-track-click"
data-track-action="copyrightLink"
data-track-category="footerClicked"
data-track-label="https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/"
data-track-options='{"dimension29": "© Crown copyright"}'
data-track-links-only
data-ga4-link="<%= {
"event_name": "navigation",
"section": "Copyright",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
}.to_json unless disable_ga4
%>
<%= content_tag :div, class: classes, data: { module: "gem-toggle metadata" } do %>
<dl class="gem-c-metadata__list" data-module="gem-track-click">
<dl class="gem-c-metadata__list">
<% if from.any? %>
<dt class="gem-c-metadata__term"><%= t("components.metadata.from") %>:</dt>
<dd class="gem-c-metadata__definition">
Expand All @@ -61,10 +61,7 @@
<%= last_updated %>
<% if local_assigns.include?(:see_updates_link) %>
&#8212; <a href="#full-publication-update-history"
class="gem-c-metadata__definition-link govuk-!-display-none-print js-see-all-updates-link"
data-track-category="content-history"
data-track-action="see-all-updates-link-clicked"
data-track-label="history">
class="gem-c-metadata__definition-link govuk-!-display-none-print js-see-all-updates-link">
<%= t("components.metadata.see_all_updates") %>
</a>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@
<a class="govuk-link govuk-pagination__link"
href="<%= previous_page[:url] %>"
rel="prev"
data-track-category="contentsClicked"
data-track-action="previous"
data-track-label="<%= previous_page[:url] %>"
data-track-dimension="previous"
data-track-dimension-index="29"
<% unless disable_ga4 %>
data-ga4-link = "<%= {
event_name: "navigation",
Expand Down Expand Up @@ -58,11 +53,6 @@
<a class="govuk-link govuk-pagination__link"
href="<%= next_page[:url] %>"
rel="next"
data-track-category="contentsClicked"
data-track-action="next"
data-track-label="<%= next_page[:url] %>"
data-track-dimension="next"
data-track-dimension-index="29"
<% unless disable_ga4 %>
data-ga4-link = "<%= {
event_name: "navigation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,13 @@ examples:
description: |
If a `href` attribute is present, `data_attributes` will apply to the `span` containing the number value (see below).
Note that the component does not include built in tracking. If this is required consider using the [track click script](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics/track-click.md).
Note that the component does not include built in tracking. If this is required consider using the [GA4 link tracker](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/trackers/ga4-link-tracker.md).
data:
number: 23
label: Ministerial departments
href: "/government/organisations#ministerial_departments"
data_attributes:
track-category: homepageClicked
track-action: departmentsLink
track-label: "/government/organisations#ministerial_departments"
track-dimension: 23 Ministerial departments
track-dimension-index: 29
department-count: true
with_data_attributes_but_no_link:
data:
number: 23
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ examples:
start: true
href: '#'
with_data_attributes:
description: Data attributes can be applied as required. Note that the component does not include built in tracking. If this is required consider using the [track click script](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics/track-click.md).
description: Data attributes can be applied as required. Note that the component does not include built in tracking. If this is required consider using the [GA4 link tracker](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/trackers/ga4-link-tracker.md).
data:
text: Track this!
margin_bottom: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,29 @@ examples:
public_updated_at: 2016-09-05 16:48:27
document_type: 'Statutory guidance'
with_data_attributes_on_links:
description: Note that the component does not include built in Universal Analytics tracking. If this is required consider using the [track click script](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics/track-click.md).
data:
items:
- link:
text: 'School behaviour and attendance: parental responsibility measures'
path: '/government/publications/parental-responsibility-measures-for-behaviour-and-attendance'
data_attributes:
track_category: 'navDocumentCollectionLinkClicked'
track_action: 1.1
track_label: '/government/publications/parental-responsibility-measures-for-behaviour-and-attendance'
track_options:
dimension28: 2
dimension29: 'School behaviour and attendance: parental responsibility measures'
a_thing: 'hello'
another_thing: 'there'
more_things:
look: 'over'
there: 'now'
metadata:
public_updated_at: 2017-01-05 14:50:33
document_type: 'Statutory guidance'
- link:
text: 'School exclusion'
path: '/government/publications/school-exclusion'
data_attributes:
track_category: 'navDocumentCollectionLinkClicked'
track_action: 1.2
track_label: '/government/publications/school-exclusion'
track_options:
dimension28: 2
dimension29: 'School exclusion'
a_thing: 'hello'
another_thing: 'there'
more_things:
look: 'over'
there: 'now'
metadata:
public_updated_at: 2017-07-19 15:01:48
document_type: 'Statutory guidance'
Expand Down Expand Up @@ -306,11 +303,7 @@ examples:
path: '/universal-credit/eligibility'
description: 'You may be able to get Universal Credit if: you’re on a low income or out...'
data_attributes:
track_category: 'resultPart'
track_action: 2
track_label: 'Result part 2'
track_options:
dimension82: 2
an_attribute: some_value
- link:
text: 'Criteria'
description: 'no url provided, just text'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ examples:
description: |
The example shown applies a tracking attribute specifically for use by Google Tag Manager in [Content Publisher](https://github.com/alphagov/content-publisher).
Other data attributes can also be applied as required. Note that the component does not include built in tracking. If this is required consider using the [track click script](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics/track-click.md).
Other data attributes can also be applied as required. Note that the component does not include built in tracking. If this is required consider using the [GA4 link tracker](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/trackers/ga4-link-tracker.md).
data:
message: Message to alert the user to a unsuccessful action goes here
description: A further description
Expand Down
11 changes: 0 additions & 11 deletions app/views/govuk_publishing_components/components/docs/govspeak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -504,17 +504,6 @@ examples:
block: |
<p>This content has a YouTube livestream link, converted to an accessible embedded player by component JavaScript.</p>
<p><a href="https://www.youtube.com/embed/live_stream?channel=UCoMdktPbSTixAyNGwb-UYkQ">Livestream video</a></p>
with_youtube_analytics:
data:
block: |
<p>This content has a YouTube link with analytics, converted to an accessible embedded player by component JavaScript.</p>
<p>
<a href="https://www.youtube.com/watch?v=ucjmWjJ25Ho"
data-youtube-player-analytics="true"
data-youtube-player-analytics-category="demo-for-components">
Youtube video with tracking
</a>
</p>
with_youtube_embed_disabled:
data:
disable_youtube_expansions: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ body: |
the correct analytics identifier metadata tags.
These are additionally used by the <a href="https://github.com/alphagov/govuk-browser-extension">GOV.UK browser extension</a> to provide details about a given page.
The code which reads the meta tags can be found <a href="https://github.com/alphagov/govuk_publishing_components/blob/main/app/assets/javascripts/govuk_publishing_components/analytics/custom-dimensions.js">in custom-dimensions.js</a>.
accessibility_criteria: |
The analytics meta tags component should not be visible to any users.
display_html: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ examples:
- value: sombrero
label: Sombrero
id: sombrero
with_tracking:
with_data_attributes_on_checkboxes:
data:
key: list_of_shoes
title: List of shoes
Expand All @@ -133,29 +133,17 @@ examples:
label: Trainers
id: trainers
data_attributes:
track_category: "filterClicked"
track_action: "List of shoes"
track_label: "trainers"
track_options:
dimension28: 1
an_attribute: some_value1
- value: plimsolls
label: Plimsolls
id: plimsolls
data_attributes:
track_category: "filterClicked"
track_action: "List of shoes"
track_label: "plimsolls"
track_options:
dimension28: 1
an_attribute: some_value2
- value: high_heels
label: High heels
id: high_heels
data_attributes:
track_category: "filterClicked"
track_action: "List of shoes"
track_label: "high_heels"
track_options:
dimension28: 1
an_attribute: some_value3
with_button_data_attributes:
description: Allows data attributes to be passed to the component to be added to the expand/collapse button. The attributes are written to the parent element then read by the JavaScript and applied to the button. This is used for tracking purposes.
data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ examples:
The example shown applies a tracking attribute specifically for use by Google Tag Manager in [Content Publisher](https://github.com/alphagov/content-publisher).
Other data attributes can also be applied as required. Note that the component does not include built in tracking. If this is required consider using the [track click script](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics/track-click.md).
Other data attributes can also be applied as required. Note that the component does not include built in tracking. If this is required consider using the [GA4 link tracker](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/trackers/ga4-link-tracker.md).
data:
sortable: true
head:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ examples:
description: |
The example shown applies a tracking attribute specifically for use by Google Tag Manager in [Content Publisher](https://github.com/alphagov/content-publisher).
Other data attributes can also be applied as required. Note that the component does not include built in tracking. If this is required consider using the [track click script](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics/track-click.md).
Other data attributes can also be applied as required. Note that the component does not include built in tracking. If this is required consider using the [GA4 link tracker](https://github.com/alphagov/govuk_publishing_components/blob/main/docs/analytics-ga4/trackers/ga4-link-tracker.md).
data:
tabs:
- id: "tab-with-data-attributes-1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="govuk-header__logo gem-c-header__logo">
<a href="<%= logo_link %>" class="govuk-header__link govuk-header__link--homepage" data-module="gem-track-click" data-track-category="homeLinkClicked" data-track-action="homeHeader">
<a href="<%= logo_link %>" class="govuk-header__link govuk-header__link--homepage">
<svg
focusable="false"
role="img"
Expand Down
2 changes: 1 addition & 1 deletion docs/component-wrapper-helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ The component wrapper includes several methods to make managing options easier,
component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns)
component_helper.add_class("gem-c-example govuk-example") # combines the given class with any passed classes
component_helper.set_id("my-id") # overrides any passed 'id' with this one (can only have one id)
component_helper.add_data_attribute({ module: "ga4-event-tracker" }) # combines any passed 'data_attributes' with those given, merging duplicate keys, e.g. if `{ module: "gem-track-click", a: "1" }` had been passed, would result in `{ module: "ga4-event-tracker gem-track-click", a: "1" }`
component_helper.add_data_attribute({ module: "ga4-event-tracker" }) # combines any passed 'data_attributes' with those given, merging duplicate keys, e.g. if `{ module: "ga4-link-tracker", a: "1" }` had been passed, would result in `{ module: "ga4-event-tracker ga4-link-tracker", a: "1" }`
component_helper.add_aria_attribute({ label: "my-label" }) # works like 'add_data_attribute'
component_helper.add_role("button") # works like 'add_class'
component_helper.set_lang("en") # works like 'set_id' (can only have one lang)
Expand Down
5 changes: 2 additions & 3 deletions spec/components/contextual_footer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def component_name
}
render_component(content_item:)

assert_select ".gem-c-related-navigation[data-module='gem-track-click ga4-link-tracker']"
assert_select ".gem-c-related-navigation[data-module='ga4-link-tracker']"
assert_select ".gem-c-related-navigation__section-link[data-ga4-link='{\"event_name\":\"navigation\",\"type\":\"contextual footer\",\"index_section\":\"1\",\"index_link\":\"1\",\"index_section_count\":\"1\",\"index_total\":\"2\",\"section\":\"Explore the topic\"}']", text: "Skating"
assert_select ".gem-c-related-navigation__section-link[data-ga4-link='{\"event_name\":\"navigation\",\"type\":\"contextual footer\",\"index_section\":\"1\",\"index_link\":\"2\",\"index_section_count\":\"1\",\"index_total\":\"2\",\"section\":\"Explore the topic\"}']", text: "Paragliding"
end
Expand All @@ -73,8 +73,7 @@ def component_name
}

render_component(content_item:, disable_ga4: true)
assert_select ".gem-c-related-navigation[data-module='gem-track-click']"
assert_select ".gem-c-related-navigation[data-module='gem-track-click ga4-link-tracker']", false
assert_select ".gem-c-related-navigation[data-module='ga4-link-tracker']", false
assert_select ".gem-c-related-navigation__section-link[data-ga4-link]", false
end
end
Loading

0 comments on commit b15181f

Please sign in to comment.