Skip to content

Commit

Permalink
Merge pull request ampproject#1904 from gduchene/master
Browse files Browse the repository at this point in the history
Use a proper correlator value for doubleclick.js
  • Loading branch information
cramforce committed Feb 11, 2016
2 parents b5343b5 + 4d20b1e commit 63f786b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ads/doubleclick.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,21 @@ export function doubleclick(global, data) {
parseInt(data.overrideWidth || data.width, 10),
parseInt(data.overrideHeight || data.height, 10)
]];
const clientId = window.context.clientId;
const pageViewId = window.context.pageViewId;
let correlator = null;
if (clientId != null) {
correlator = pageViewId + (clientId.replace(/\D/g, '') % 1e6) * 1e6;
} else {
correlator = pageViewId;
}
const pubads = googletag.pubads();
const slot = googletag.defineSlot(data.slot, dimensions, 'c')
.addService(pubads);
pubads.enableSingleRequest();
pubads.markAsAmp();
pubads.set('page_url', context.canonicalUrl);
pubads.setCorrelator(Number(correlator));
googletag.enableServices();

if (data.targeting) {
Expand Down

0 comments on commit 63f786b

Please sign in to comment.