Skip to content

Commit 025484e

Browse files
author
George Haberis
committed
append abTestParticipations to xcust
1 parent 5d38a82 commit 025484e

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

dotcom-rendering/src/components/EnhanceAffiliateLinks.importable.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ import { useBetaAB } from '../lib/useAB';
1818
export 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,

0 commit comments

Comments
 (0)