Skip to content

Commit

Permalink
#201, comparing screen views and events
Browse files Browse the repository at this point in the history
  • Loading branch information
Librelio Dev committed Mar 1, 2015
1 parent e4bcd83 commit 4307a7f
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 5 deletions.
70 changes: 68 additions & 2 deletions src/admin_assets/js/pages/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,12 @@ gapi.analytics.ready(function()
metrics: 'ga:totalEvents',
'start-date':'2005-01-01',
dimensions: 'ga:eventLabel,ga:yearMonth,ga:operatingSystem',
filters: 'ga:eventAction=@Succeeded'
filters: 'ga:eventAction=@Succeeded',
'max-results':10000
}
});
report.on('success', function(response) {
//console.log(response);
var data = response.rows;
var publications = [];
data.forEach(function(d, i) {
Expand All @@ -183,7 +185,7 @@ gapi.analytics.ready(function()



console.log(publications);
//console.log(publications);

var sum = $.pivotUtilities.aggregatorTemplates.sum;
var numberFormat = $.pivotUtilities.numberFormat;
Expand All @@ -208,6 +210,70 @@ gapi.analytics.ready(function()


report.execute();

var report2 = new gapi.analytics.report.Data({
query: {
ids: 'ga:' + ga_profile.id,
metrics: 'ga:uniqueScreenviews',
'start-date':'2005-01-01',
dimensions: 'ga:screenName,ga:yearMonth,ga:operatingSystem',
filters: 'ga:screenName=@Downloading/',
'max-results':10000

}
});
report2.on('success', function(response) {
//console.log(response);
var data = response.rows;
var publications2 = [];
data.forEach(function(d, i) {
console.log(d[0]);
d.filePath=d[0].match(/\/\/?(.[^\?]+)(.*)/)[1];
parts = d[0].match(/(.*)\/(.*)/);
if (parts){
d.fileName = parts[2];
var obj = {};
obj.Publication= d.fileName;
obj.YearMonth = d[1]
obj.OS = d[2]
obj.Qty = +d[3];
obj.Type='Free'
if (d.fileName.lastIndexOf('_') == d.fileName.length - 1) {
obj.Type='Paid';//Paid publications have a file name ending with _
obj.Publication = d.fileName.substring(0, d.fileName.length - 1);//Remove final _
}
publications2.push(obj);

}
});



console.log(publications2);

var sum = $.pivotUtilities.aggregatorTemplates.sum;
var numberFormat = $.pivotUtilities.numberFormat;
var intFormat = numberFormat({digitsAfterDecimal: 0});

$("#pivotstable2").pivotUI(
publications2,
{
rows: ["Publication"],
cols: ["Type"],
aggregators: {"Quantity":function() { return sum(intFormat)(["Qty"]) }},
hiddenAttributes: ["Qty"]
}


);




});


report2.execute();

}
});
Expand Down
16 changes: 13 additions & 3 deletions src/templates/pages/tracking.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ javascripts:
---

<div class="col-lg-12">
<div class="box">
<div id="collapse4" class="body">
<div id="page-loading-indicator">
<img src="assets/img/loader-big-snake.gif" alt="Loading..." />
</div>
<div id="auth-button-wrp"></div>
<div id="date-range-selector-1-container"></div>
</div>
</div>
</div>

<div class="col-lg-12">
<div class="box">
Expand All @@ -51,8 +61,8 @@ javascripts:
<h5 localize="">Downloads</h5>
</header>
<div class="body">
<div id="pivotstable">
</div>
<div id="pivotstable"></div>
<div id="pivotstable2"></div>

</div>
</div>
Expand Down

0 comments on commit 4307a7f

Please sign in to comment.