-
Notifications
You must be signed in to change notification settings - Fork 30
Fix Affiliate Disclaimer tracking #15074
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
base: main
Are you sure you want to change the base?
Conversation
|
@guardian/the-filter I wouldn't mind getting some feedback on this WIP. I've made the change to split out the 3 components However when doing so I noted 2 Affiliate Disclaimer detect tracking events being fired on an article with affiliate links, this was because 2 affiliate disclaimers were rendered, although only 1 is actually displayed on the page dependent on breakpoint. We only want 1 event fired so I applied a workaround by tracking An alternative option I'd considered was to switch to 'view' instead of 'idle' in the code below... <Island priority="enhancement" defer={{ until: 'idle' }}>
<AffiliateDisclaimer />
</Island>becomes... <Island priority="enhancement" defer={{ until: 'view' }}>
<AffiliateDisclaimer />
</Island>This would mean the tracking event is only fired if the Affiliate Disclaimer is viewed so we wouldn't trigger the event for disclaimers rendered but not visible, if I were to do this I'd update the event action from 'DETECT' to 'VIEW' which is more accurate. |
Is this a good use case for something like useOnce? Looks like this provides an existing way of doing what you've described, so you would replace checking the value of |
|
Hello 👋! When you're ready to run Chromatic, please apply the You will need to reapply the label each time you want to run Chromatic. |
What does this change?
Introduces an Ophan tracking event to detect when the Affiliate Disclaimer has been rendered. Changes in order to achieve this:
AffiliateDisclaimer,AffiliateDisclaimerInlineandGalleryAffiliateDisclaimercomponents previously exported byAffiliateDisclaimer.tsxin to 3 seperate importable modulesAffiliateDisclaimer.importable.tsx,AffiliateDisclaimerInline.importable.tsxandGalleryAffiliateDisclaimer.importable.tsx- it's a requirement of Islands that the component matches the module name.AffiliateDisclaimer,AffiliateDisclaimerInlineandGalleryAffiliateDisclaimerin<Island />components as they will now rehydrate in the client.affiliateDisclaimerHelpers.tsxfor providing shared logic eg. the tracking logic and the disclaimer text component, this is shared byAffiliateDisclaimer.importable.tsx,AffiliateDisclaimerInline.importable.tsxandGalleryAffiliateDisclaimer.importable.tsx@guardian/ophan-tracker-jslibrary to the latest version which includes the new component typeAFFILIATE_DISCLAIMER