Skip to content
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

Tag GLADE opt out requests with tracking experiment id. #3111

Merged
merged 1 commit into from
May 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions ads/google/doubleclick.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
import {loadScript, checkData} from '../../src/3p';
import {getCorrelator} from './utils';

/**
* @enum {number}
* @private
*/
const GladeExperiment = {
NO_EXPERIMENT: 0,
GLADE_CONTROL: 1,
GLADE_OPT_OUT: 2,
};

/**
* @param {!Window} global
* @param {!Object} data
Expand All @@ -32,25 +42,27 @@ export function doubleclick(global, data) {
]);

if (data.useSameDomainRenderingUntilDeprecated != undefined) {
doubleClickWithGpt(global, data, false);
doubleClickWithGpt(global, data, GladeExperiment.GLADE_OPT_OUT);
} else {
const dice = Math.random();
const href = global.context.location.href;
if ((href.indexOf('google_glade=1') > 0 || dice < experimentFraction)
&& href.indexOf('google_glade=0') < 0) {
doubleClickWithGlade(global, data);
} else {
doubleClickWithGpt(global, data, dice < 2 * experimentFraction);
const exp = (dice < 2 * experimentFraction) ?
GladeExperiment.GLADE_CONTROL : GladeExperiment.NO_EXPERIMENT;
doubleClickWithGpt(global, data, exp);
}
}
}

/**
* @param {!Window} global
* @param {!Object} data
* @param {boolean} isGladeControl
* @param {!GladeExperiment} gladeExperiment
*/
function doubleClickWithGpt(global, data, isGladeControl) {
function doubleClickWithGpt(global, data, gladeExperiment) {
const dimensions = [[
parseInt(data.overrideWidth || data.width, 10),
parseInt(data.overrideHeight || data.height, 10),
Expand All @@ -71,8 +83,10 @@ function doubleClickWithGpt(global, data, isGladeControl) {
const slot = googletag.defineSlot(data.slot, dimensions, 'c')
.addService(pubads);

if (isGladeControl) {
if (gladeExperiment === GladeExperiment.GLADE_CONTROL) {
pubads.markAsGladeControl();
} else if (gladeExperiment === GladeExperiment.GLADE_OPT_OUT) {
pubads.markAsGladeOptOut();
}

pubads.markAsAmp();
Expand Down