simorgh
simorgh copied to clipboard
[WS-1086 Spike] - Add read time to promo click tracking on homepages
Resolves JIRA: Summary
This objective of this spike was to provide more information on how to best add the read time to the tracking of individual promos when clicked on in the homepages.
This PR demonstrates a possible implementation in conjunction with the prototype frontend work from https://github.com/bbc/simorgh/pull/13080.
Notable points of discovery:
- There are currently two 'base'
Promocomponents.- This legacy
Promocomponent used in the Curations written in JS - This
OptimoPromoscomponent which is used in a wider variety of places written in TS
- This legacy
- The legacy
Promocomponent does not have any tracking in the component itself, whereasOptimoPromoshas aneventTrackingDataprop and makes use of the viewability model. - Prior to the work done in https://github.com/bbc/simorgh/pull/13078, part of this spike was trying to determine whether it would make more sense to just add tracking to the legacy
Promocomponent using theuseClickTracker()hook in a similar fashion to how it is implemented inOptimoPromos, or whether it would be worth refactoring the Curations to use the newerOptimoPromowhich already allows tracking to be added.- Given that https://github.com/bbc/simorgh/pull/13078 is completed and merged now, it probably makes more sense for the work related to the read time experiment on home pages to go with an approach that builds on this rather than refactor relevant components to use the
OptimoPromoscomponent instead. However, this should be further explored as tech debt elsewhere. - Minimal changes were required to add the read time data to the tracking object following these changes.
- Given that https://github.com/bbc/simorgh/pull/13078 is completed and merged now, it probably makes more sense for the work related to the read time experiment on home pages to go with an approach that builds on this rather than refactor relevant components to use the
Code changes
- Adds read time as
labelanddurationin theselectevent sent when a promo is clicked in Grid Components (bothHierarchicalGridandCurationGrid)- These were based on how the events were setup for the Article page experiment, though these can be changed if necessary.
- Adds read time as optional parameter in
buildPromoEventTrackingData
Testing
- [x] Manual Testing required?
- [x] Local (
Ready-For-Test, Local) - [ ] Test (
Ready-For-Test, Test) - [ ] Preview (
Ready-For-Test, Preview) - [ ] Live (
Ready-For-Test, Live)
- [x] Local (
- [ ] Manual Testing complete?
- [ ] Local
- [ ] Test
- [ ] Preview
- [ ] Live
Additional Testing Steps
Verify that the select event is sent when a Promo on the homepage is clicked and that the read time can be found in the payload.
- Visit any homepage (e.g. http://localhost:7080/pidgin?renderer_env=live)
- When inspecting the page, reload the page and view the events either under the Network tab or the Tag Inspector (Tag Inspector was less reliable when it came to seeing the
selectevent however). - If using the Network tab, ensure 'Preserve log' is checked.
- Click on a promo, verify the event is sent with the correct payload (The event should begin with
hit.xiti?s) Example payload of random promo from Pidgin homepage:
[
{
name: 'viewability.select',
data: {
group: {
name: 'Top Tori',
type: 'hierarchical-curation-grid',
item_count: 9,
resource_id: 'urn:bbc:tipo:list:41c2dccc-4711-4e01-85d4-72d531765fa8',
position: 1,
},
event: { category: 'viewability', action: 'select' },
user: { id: null },
app: { type: 'responsive', name: 'news-pidgin' },
item: {
name: 'hierarchical-curation-grid',
link: 'https://www.bbc.com/pidgin/articles/cx2xz74ye56o',
type: 'hierarchical-curation-grid-promo',
text: 'Wetin be geo-tagging of PoS wey CBN give operators ultimatum to activate and how e go work in 60 days',
position: 2,
duration: 300000,
media_type: 'article',
label: 'Read time: 5 minutes',
resource_id: 'cx2xz74ye56o',
},
},
},
];
Useful Links
- Coding Standards
- Repository use guidelines
- Add Links to useful resources related to this PR if applicable.