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

Add GA4 tracking to details in attachments #3165

Merged
merged 1 commit into from
Apr 22, 2024
Merged

Conversation

andysellick
Copy link
Contributor

@andysellick andysellick commented Apr 19, 2024

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

What / why

Add GA4 tracking attributes to details components within attachment components on publication pages.

The tracking for the details components is mostly handled automatically, but the component can't determine the value for index_section_count (the total number of related things being tracked) so this must be passed to the component. In this case it is the number of attachments that have a details component showing, which is not necessarily the same as the total number of attachments.

Some example pages to test:

Also removes some unnecessary data from the tests in the same file.

Visual changes

None.

Trello card: https://trello.com/c/xhASj1rp/765-add-tracking-to-details-component

@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3165 April 19, 2024 16:10 Inactive
@andysellick andysellick requested a review from KludgeKML April 19, 2024 16:11
@andysellick andysellick force-pushed the ga4-attachments-details branch from 764d90a to b19b4be Compare April 19, 2024 16:14
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-3165 April 19, 2024 16:14 Inactive
@andysellick andysellick requested a review from AshGDS April 22, 2024 08:14
Copy link
Contributor

@AshGDS AshGDS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@@ -14,6 +14,10 @@ def attachments_for_components
documents.select { |doc| featured_attachments.include? doc["id"] }
end

def attachments_with_details
attachments_for_components.select { |doc| doc["accessible"] == false && doc["alternative_format_contact_email"] }.count
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more for my own curiosity - could doc["accessible"] == false be shortened to !doc["accessible"], or does it need to specifically be a false boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it needs to be a false boolean, but @KludgeKML can confirm.

@andysellick andysellick merged commit 5d6f042 into main Apr 22, 2024
15 checks passed
@andysellick andysellick deleted the ga4-attachments-details branch April 22, 2024 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants