Skip to content

Commit

Permalink
Merge pull request #1658 from cramforce/doubleclick-cid
Browse files Browse the repository at this point in the history
Google Analytics integration
  • Loading branch information
cramforce committed Feb 3, 2016
2 parents 085d0a7 + 798e527 commit 14d9a2e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ads/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ export const adPreconnect = {
export const clientIdScope = {
// Add a mapping like
// adNetworkType: 'cidScope' here.
adsense: 'AMP_ECID_GOOGLE',
doubleclick: 'AMP_ECID_GOOGLE',
};
7 changes: 7 additions & 0 deletions ads/adsense.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ import {checkData} from '../src/3p';
*/
export function adsense(global, data) {
checkData(data, ['adClient', 'adSlot']);
if (global.context.clientId) {
// Read by GPT for GA/GPT integration.
global.gaGlobal = {
vid: global.context.clientId,
hid: global.context.pageViewId,
};
}
/*eslint "google-camelcase/google-camelcase": 0*/
global.google_page_url = global.context.canonicalUrl;
const s = document.createElement('script');
Expand Down
7 changes: 7 additions & 0 deletions ads/doubleclick.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ export function doubleclick(global, data) {
'tagForChildDirectedTreatment', 'cookieOptions',
'overrideWidth', 'overrideHeight',
]);
if (global.context.clientId) {
// Read by GPT for GA/GPT integration.
global.gaGlobal = {
vid: global.context.clientId,
hid: global.context.pageViewId,
};
}
loadScript(global, 'https://www.googletagservices.com/tag/js/gpt.js', () => {
global.googletag.cmd.push(function() {
const googletag = global.googletag;
Expand Down
3 changes: 2 additions & 1 deletion extensions/amp-analytics/0.1/vendors.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export const ANALYTICS_CONFIG = {
'host': 'https://www.google-analytics.com',
'basePrefix': 'v=1&_v=a0&aip=true&_s=${requestCount}' +
'dt=${title}&sr=${screenWidth}x${screenHeight}&_utmht=${timestamp}&' +
'jid=&cid=${clientId(_ga)}&tid=${account}&dl=${documentLocation}&' +
'jid=&cid=${clientId(AMP_ECID_GOOGLE)}&tid=${account}&' +
'dl=${documentLocation}&' +
'dr=${documentReferrer}&sd=${screenColorDepth}&' +
'ul=${browserLanguage}&de=${documentCharset}' ,
'baseSuffix': '&a=${pageViewId}&z=${random}',
Expand Down

0 comments on commit 14d9a2e

Please sign in to comment.