Skip to content

Commit 1485133

Browse files
authored
Merge pull request #520 from mcserep/ga-file-content-load
Track file browsing with Google Analytics
2 parents 12aa416 + 84eacca commit 1485133

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

webgui/scripts/codecompass/view/component/Text.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,14 @@ function (declare, domClass, dom, style, query, topic, ContentPane, Dialog,
342342
this.set('header', this._fileInfo);
343343

344344
this._getSyntaxHighlight(this._fileInfo);
345+
346+
if (gtag) {
347+
gtag('event', 'page_view', {
348+
page_location: window.location.href,
349+
page_path: window.location.pathname + window.location.hash,
350+
page_title: urlFileInfo.path
351+
});
352+
}
345353
},
346354

347355
/**

webgui/scripts/ga.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
var gtag = null;
12
$(document).ready(function() {
23
$.ajax({
34
url: 'ga.txt',
@@ -8,7 +9,7 @@ $(document).ready(function() {
89

910
window.dataLayer = window.dataLayer || [];
1011

11-
function gtag() {
12+
gtag = function() {
1213
dataLayer.push(arguments);
1314
}
1415

0 commit comments

Comments
 (0)