Created
January 3, 2018 09:00
-
-
Save ipansensoy/06798cc104115b67dc48c4e45bbb9021 to your computer and use it in GitHub Desktop.
// source https://jsbin.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
var pushMetrics = function(slot, time) { | |
this.products = this.products || []; | |
var resp = slot.getResponseInformation(); | |
var vals = []; | |
vals.push('advertiserId:' + resp.advertiserId); | |
vals.push('campaignId:' + resp.campaignId); | |
vals.push('creativeId:' + resp.creativeId); | |
vals.push('lineItemId:' + resp.lineItemId); | |
vals.push('timeToLoad:' + parseInt(time)); | |
console.log('products',this.products); | |
if (this.products.length) { | |
var self = this; | |
window.mready = window.mready || []; | |
window.mready.push(function(metrics) { | |
metrics.ev({ | |
products: self.products, | |
eVar116: vals.join('|') | |
}); | |
}); | |
} | |
} | |
window.googletag = window.googletag || {}; | |
window.googletag.cmd = window.googletag.cmd || []; | |
window.googletag.cmd.push(function() { | |
googletag.pubads().addEventListener('impressionViewable', function(e) { | |
console.log('impressionViewable', e); | |
//pushMetrics(); | |
}); | |
googletag.pubads().addEventListener('slotRenderEnded', function(e) { | |
console.log('slotRenderEnded', e); | |
//pushMetrics(); | |
}); | |
googletag.pubads().addEventListener('slotOnload', function(e) { | |
console.log('slotOnload', e); | |
pushMetrics(e.slot, window.performance.now()); | |
}); | |
googletag.pubads().addEventListener('slotVisibilityChanged', function(e) { | |
console.log('slotVisibilityChanged', e); | |
//pushMetrics(); | |
}); | |
}); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var pushMetrics = function(slot, time) { | |
this.products = this.products || []; | |
var resp = slot.getResponseInformation(); | |
var vals = []; | |
vals.push('advertiserId:' + resp.advertiserId); | |
vals.push('campaignId:' + resp.campaignId); | |
vals.push('creativeId:' + resp.creativeId); | |
vals.push('lineItemId:' + resp.lineItemId); | |
vals.push('timeToLoad:' + parseInt(time)); | |
console.log('products',this.products); | |
if (this.products.length) { | |
var self = this; | |
window.mready = window.mready || []; | |
window.mready.push(function(metrics) { | |
metrics.ev({ | |
products: self.products, | |
eVar116: vals.join('|') | |
}); | |
}); | |
} | |
} | |
window.googletag = window.googletag || {}; | |
window.googletag.cmd = window.googletag.cmd || []; | |
window.googletag.cmd.push(function() { | |
googletag.pubads().addEventListener('impressionViewable', function(e) { | |
console.log('impressionViewable', e); | |
//pushMetrics(); | |
}); | |
googletag.pubads().addEventListener('slotRenderEnded', function(e) { | |
console.log('slotRenderEnded', e); | |
//pushMetrics(); | |
}); | |
googletag.pubads().addEventListener('slotOnload', function(e) { | |
console.log('slotOnload', e); | |
pushMetrics(e.slot, window.performance.now()); | |
}); | |
googletag.pubads().addEventListener('slotVisibilityChanged', function(e) { | |
console.log('slotVisibilityChanged', e); | |
//pushMetrics(); | |
}); | |
});</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pushMetrics = function(slot, time) { | |
this.products = this.products || []; | |
var resp = slot.getResponseInformation(); | |
var vals = []; | |
vals.push('advertiserId:' + resp.advertiserId); | |
vals.push('campaignId:' + resp.campaignId); | |
vals.push('creativeId:' + resp.creativeId); | |
vals.push('lineItemId:' + resp.lineItemId); | |
vals.push('timeToLoad:' + parseInt(time)); | |
console.log('products',this.products); | |
if (this.products.length) { | |
var self = this; | |
window.mready = window.mready || []; | |
window.mready.push(function(metrics) { | |
metrics.ev({ | |
products: self.products, | |
eVar116: vals.join('|') | |
}); | |
}); | |
} | |
} | |
window.googletag = window.googletag || {}; | |
window.googletag.cmd = window.googletag.cmd || []; | |
window.googletag.cmd.push(function() { | |
googletag.pubads().addEventListener('impressionViewable', function(e) { | |
console.log('impressionViewable', e); | |
//pushMetrics(); | |
}); | |
googletag.pubads().addEventListener('slotRenderEnded', function(e) { | |
console.log('slotRenderEnded', e); | |
//pushMetrics(); | |
}); | |
googletag.pubads().addEventListener('slotOnload', function(e) { | |
console.log('slotOnload', e); | |
pushMetrics(e.slot, window.performance.now()); | |
}); | |
googletag.pubads().addEventListener('slotVisibilityChanged', function(e) { | |
console.log('slotVisibilityChanged', e); | |
//pushMetrics(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment