File tree Expand file tree Collapse file tree 1 file changed +13
-8
lines changed
dotcom-rendering/src/components Expand file tree Collapse file tree 1 file changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,16 @@ import { useBetaAB } from '../lib/useAB';
1818export const EnhanceAffiliateLinks = ( ) => {
1919 const abTests = useBetaAB ( ) ;
2020
21+ // Am I in a test at all?
22+ const abTestParticipations = abTests ?. getParticipations ( ) ;
23+
24+ // Reduce abTestParticipations to a comma-separated string
25+ const abTestString = abTestParticipations
26+ ? Object . entries ( abTestParticipations )
27+ . map ( ( [ key , value ] ) => `${ key } :${ value } ` )
28+ . join ( ',' )
29+ : '' ;
30+
2131 useEffect ( ( ) => {
2232 const allLinksOnPage = [ ...document . querySelectorAll ( 'a' ) ] ;
2333
@@ -30,15 +40,10 @@ export const EnhanceAffiliateLinks = () => {
3040
3141 const skimlinksAccountId = getSkimlinksAccountId ( link . href ) ;
3242
33- // Am I in a test at all?
34- const abTestParticipations = abTests ?. getParticipations ( ) ;
35- console . log (
36- '*** abTestParticipations ***' ,
37- abTestParticipations ,
38- ) ;
39-
4043 // Skimlinks treats xcust as one long string, so we use | to separate values
41- const xcustValue = `referrer|${ referrerDomain } |accountId|${ skimlinksAccountId } ` ;
44+ const xcustValue = `referrer|${ referrerDomain } |accountId|${ skimlinksAccountId } ${
45+ abTestString ? `|abTestParticipations|${ abTestString } ` : ''
46+ } `;
4247
4348 link . href = `${ link . href } &xcust=${ encodeURIComponent (
4449 xcustValue ,
You can’t perform that action at this time.
0 commit comments