Skip to content

Commit 36daaa2

Browse files
1% experiment - AdSense/GAM ad request ptt parameter (ampproject#30764)
* 1% AdSense/GAM ad ptt parameter experiment * prettify * address feedback * review feedback * lint
1 parent 5ad23a7 commit 36daaa2

File tree

6 files changed

+62
-4
lines changed

6 files changed

+62
-4
lines changed

build-system/global-configs/canary-config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@
3535
"amp-ad-no-center-css": 0,
3636
"analytics-chunks": 1,
3737
"render-on-idle-fix": 1,
38-
"build-in-chunks": 1
38+
"build-in-chunks": 1,
39+
"adsense-ptt-exp": 0.02,
40+
"doubleclick-ptt-exp": 0.02
3941
}

build-system/global-configs/prod-config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,7 @@
3333
"swg-gpay-api": 1,
3434
"swg-gpay-native": 1,
3535
"amp-ad-no-center-css": 0,
36-
"analytics-chunks": 1
36+
"analytics-chunks": 1,
37+
"adsense-ptt-exp": 0.02,
38+
"doubleclick-ptt-exp": 0.02
3739
}

extensions/amp-ad-network-adsense-impl/0.1/amp-ad-network-adsense-impl.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ import {domFingerprintPlain} from '../../../src/utils/dom-fingerprint';
5353
import {getAmpAdRenderOutsideViewport} from '../../amp-ad/0.1/concurrent-load';
5454
import {getData} from '../../../src/event-helper';
5555
import {getDefaultBootstrapBaseUrl} from '../../../src/3p-frame';
56+
import {
57+
getExperimentBranch,
58+
randomlySelectUnsetExperiments,
59+
} from '../../../src/experiments';
5660
import {getMode} from '../../../src/mode';
5761
import {insertAnalyticsElement} from '../../../src/extension-analytics';
58-
import {randomlySelectUnsetExperiments} from '../../../src/experiments';
5962
import {removeElement} from '../../../src/dom';
6063
import {stringHash32} from '../../../src/string';
6164
import {utf8Decode} from '../../../src/utils/bytes';
@@ -66,6 +69,15 @@ const ADSENSE_BASE_URL = 'https://googleads.g.doubleclick.net/pagead/ads';
6669
/** @const {string} */
6770
const TAG = 'amp-ad-network-adsense-impl';
6871

72+
/** @const {string} */
73+
const PTT_EXP = 'adsense-ptt-exp';
74+
75+
/** @const @enum{string} */
76+
const PTT_EXP_BRANCHES = {
77+
CONTROL: '21068091',
78+
EXPERIMENT: '21068092',
79+
};
80+
6981
/**
7082
* Shared state for AdSense ad slots. This is used primarily for ad request url
7183
* parameters that depend on previous slots.
@@ -220,7 +232,13 @@ export class AmpAdNetworkAdsenseImpl extends AmpA4A {
220232
* @visibleForTesting
221233
*/
222234
divertExperiments() {
223-
const experimentInfoList = /** @type {!Array<!../../../src/experiments.ExperimentInfo>} */ ([]);
235+
const experimentInfoList = /** @type {!Array<!../../../src/experiments.ExperimentInfo>} */ ([
236+
{
237+
experimentId: PTT_EXP,
238+
isTrafficEligible: () => true,
239+
branches: Object.values(PTT_EXP_BRANCHES),
240+
},
241+
]);
224242
const setExps = randomlySelectUnsetExperiments(
225243
this.win,
226244
experimentInfoList
@@ -323,6 +341,10 @@ export class AmpAdNetworkAdsenseImpl extends AmpA4A {
323341
'format': format,
324342
'w': sizeToSend.width,
325343
'h': sizeToSend.height,
344+
'ptt':
345+
getExperimentBranch(this.win, PTT_EXP) === PTT_EXP_BRANCHES.EXPERIMENT
346+
? 12
347+
: null,
326348
'iu': slotname,
327349
'npa':
328350
consentState == CONSENT_POLICY_STATE.INSUFFICIENT ||

extensions/amp-ad-network-adsense-impl/0.1/test/test-amp-ad-network-adsense-impl.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,14 @@ describes.realWin(
731731
/(\?|&)is_amp=5(&|$)/
732732
);
733733
});
734+
it('does not set ptt parameter by default', () =>
735+
expect(impl.getAdUrl()).to.not.eventually.match(/(\?|&)ptt=(&|$)/));
736+
it('sets ptt parameter', () => {
737+
forceExperimentBranch(impl.win, 'adsense-ptt-exp', '21068092');
738+
return expect(impl.getAdUrl()).to.eventually.match(
739+
/(\?|&)ptt=12(&|$)/
740+
);
741+
});
734742
});
735743

736744
// Not using arrow function here because otherwise the way closure behaves

extensions/amp-ad-network-doubleclick-impl/0.1/amp-ad-network-doubleclick-impl.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,15 @@ const ZINDEX_EXP_BRANCHES = {
144144
HOLDBACK: '21065357',
145145
};
146146

147+
/** @const {string} */
148+
const PTT_EXP = 'doubleclick-ptt-exp';
149+
150+
/** @const @enum{string} */
151+
const PTT_EXP_BRANCHES = {
152+
CONTROL: '21068093',
153+
EXPERIMENT: '21068094',
154+
};
155+
147156
/**
148157
* Required size to be sent with fluid requests.
149158
* @const {string}
@@ -430,6 +439,11 @@ export class AmpAdNetworkDoubleclickImpl extends AmpA4A {
430439
isTrafficEligible: () => true,
431440
branches: Object.values(ZINDEX_EXP_BRANCHES),
432441
},
442+
{
443+
experimentId: PTT_EXP,
444+
isTrafficEligible: () => true,
445+
branches: Object.values(PTT_EXP_BRANCHES),
446+
},
433447
]);
434448
const setExps = this.randomlySelectUnsetExperiments_(experimentInfoList);
435449
Object.keys(setExps).forEach(
@@ -559,6 +573,9 @@ export class AmpAdNetworkDoubleclickImpl extends AmpA4A {
559573
const {consentString, gdprApplies} = consentTuple;
560574

561575
return {
576+
'ptt': this.experimentIds.includes(PTT_EXP_BRANCHES.EXPERIMENT)
577+
? 13
578+
: null,
562579
'npa':
563580
consentTuple.consentState == CONSENT_POLICY_STATE.INSUFFICIENT ||
564581
consentTuple.consentState == CONSENT_POLICY_STATE.UNKNOWN

extensions/amp-ad-network-doubleclick-impl/0.1/test/test-amp-ad-network-doubleclick-impl.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,13 @@ describes.realWin('amp-ad-network-doubleclick-impl', realWinConfig, (env) => {
10791079
expect(url).to.not.match(/(=|%2C)2106317(3|4)(%2C|&|$)/);
10801080
});
10811081
});
1082+
1083+
it('does not set ptt parameter by default', () =>
1084+
expect(impl.getAdUrl()).to.not.eventually.match(/(\?|&)ptt=(&|$)/));
1085+
it('sets ptt parameter', () => {
1086+
impl.experimentIds = ['21068094'];
1087+
return expect(impl.getAdUrl()).to.eventually.match(/(\?|&)ptt=13(&|$)/);
1088+
});
10821089
});
10831090

10841091
describe('#getPageParameters', () => {

0 commit comments

Comments
 (0)