Merge pull request #754 from google/add-analytics-codepen

Track codepen button clicks
master
Surma 2015-07-06 20:47:19 +01:00
commit 7b31dd6285
1 changed files with 11 additions and 0 deletions

View File

@ -102,6 +102,17 @@ CodeBlockCodePen.prototype.clickHandler = function(form, pre) {
return function() {
// Track codepen button clicks
if (typeof ga !== 'undefined') {
ga('send', {
hitType: 'event',
eventCategory: 'codepen',
eventAction: 'click',
eventLabel: window.location.pathname +
(window.location.hash ? window.location.hash : '')
});
}
// Modify relative URLs to make them absolute.
var code = pre.textContent.replace('../assets/demos/',
window.location.origin + '/assets/demos/');