Add signup links index to data_attributes #3140
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
On finder pages, signup links can appear at the top and bottom of the page and they are rendered as separate modules. For GA4 analytics purposes, however, we want to treat these separate modules as if they were in the same module and combine their index values.
For example, if there are 2 signup links at the top of the page, their current index properties are
index_link: 1/2
,index_total: 2
. Similarly, if there are a further 2 signup links at the bottom of the page, their current index properties are alsoindex_link: 1/2
,index_total: 2
. We want to combine these index properties so that they becomeindex_link: 1/2/3/4
andindex_total: 4
.This PR calculates the index values in
app/presenters/signup_links_presenter.rb
and adds them to thedata_attributes
hash, which ultimately sets thedata-ga4-index
attribute in thegovuk_publishing_components/components/subscription_links
component.Credit for the code used in this PR belongs to @andysellick ⭐
Examples:
Get emails
andSubscribe to feed
)Subscribe to feed
)Why
Trello card
Visual changes
N/A