Commit cd984853 authored by khawkins98's avatar khawkins98
Browse files

Add documentation, attempt to fix duplicate rows

parent 07572ee2
......@@ -83,7 +83,7 @@ $(document).ready(function() {
// - row = result row to work; 0 = global
var render_queue_time = 1;
function render_queue(processor,row) {
render_queue_time += 500; // set requests XXms second apart
render_queue_time += 500; // set requests N ms second apart
window.setTimeout(function(){
switch (processor) {
......@@ -163,7 +163,6 @@ function fetch_traffic_overview(target,dimensions,metrics,filters,shared) {
var data1 = results[0].rows.map(function(row) { return +row[2]; });
var data2 = results[1].rows.map(function(row) { return +row[2]; });
var data = {
labels : labels,
datasets : [
......@@ -238,11 +237,11 @@ function fetch_overview(target,dimensions,metrics,filters,shared) {
if (analyticsResults[row].pageViews < 250) {
success = iconWarning;
} else if (analyticsResults[row].pageViews < 300) {
success = iconSoSo;
success = iconSoSo;
}
$(target).append('<tr class="result-'+ row + '">' +
'<td>' +
$(target).append('<tr class="result-'+ row + '">' +
'<td>' +
'<span class="label">' + parsePublicationDate(analyticsResults[row].url) + '</span>' +
'<div>' + analyticsResults[row].title + '</div>' +
'<small><a target="_blank" href="http://news.embl.de' + analyticsResults[row].url + '">'+ analyticsResults[row].url+'</a></small>'+
......@@ -250,8 +249,8 @@ function fetch_overview(target,dimensions,metrics,filters,shared) {
'<a class="readmore" href="https://analytics.google.com/analytics/web/#report/content-pages/a21480202w75912813p91186979/%3Fexplorer-table.filter%3D' + encodeURIComponent(analyticsResults[row].url) + '" target="_blank">View GA for this URL'+
'</small>' +
'</td>' +
'<td>' + success + analyticsResults[row].pageViews +
'</td><td class="tr-referals small"></td><td class="tr-ui-regions"></td><td class="tr-time-on-page"></td><td class="tr-leave-rate"></td></tr>');
'<td>' + success + analyticsResults[row].pageViews +
'</td><td class="tr-referals small"></td><td class="tr-ui-regions"></td><td class="tr-time-on-page"></td><td class="tr-leave-rate"></td></tr>');
}
......@@ -261,8 +260,8 @@ function fetch_overview(target,dimensions,metrics,filters,shared) {
// convert facebook.com/ to Facebook, etc.
function parseReferralName(siteToParse) {
var original = ['facebook','t.co', 'google','pinterest','linkedin','ebi.ac','rssfeed','direct', 'europeanmolecularbiologylaboratory.createsend1.com']
var replacements = ['Facebook','Twitter','Google','Pinterest','LinkedIn','EBI', 'RSS', 'Not specificed or bookmark', 'EMBL.createsend']
var original = ['facebook','t.co', 'google','pinterest','linkedin','ebi.ac','rssfeed','direct', 'europeanmolecularbiologylaboratory.createsend1.com']
var replacements = ['Facebook','Twitter','Google','Pinterest','LinkedIn','EBI', 'RSS', 'Not specificed or bookmark', 'EMBL.createsend']
for (var i = 0; i < original.length; i++) {
if (siteToParse.indexOf(original[i]) >= 0) {
......@@ -294,10 +293,10 @@ function fetch_page_detail(target,dimensions,metrics,filters,shared,resultPositi
Promise.all([localQuery]).then(function(results) {
var receivedData = results[0].rows;
// save the data
for (var i = 0; i < receivedData.length; i++) {
analyticsResults[resultPosition]['referals'][parseReferralName(receivedData[i][0])] = receivedData[i][1];
analyticsResults[resultPosition]['referals'][parseReferralName(receivedData[i][0])] = receivedData[i][1];
}
// sort
......@@ -308,7 +307,7 @@ function fetch_page_detail(target,dimensions,metrics,filters,shared,resultPositi
dataSorted.forEach(function(element) {
$(target+' td.tr-referals').append('<tr><td>' + element +'</td><td>' + analyticsResults[resultPosition]['referals'][element] + '</td></tr>');
});
});
}
......@@ -328,13 +327,15 @@ function fetch_ui_regions(target,dimensions,metrics,filters,shared,resultPositio
Promise.all([localQuery]).then(function(results) {
$(target + ' td.tr-ui-regions').html(''); //empty
var receivedData = results[0].rows;
// console.table(receivedData);
// track where users engaged
var totalContentClicks = 0,
totalSiteNavClicks = 0;
for (var i = 0; i < receivedData.length; i++) {
// is it a UI region?
if (receivedData[i][0].indexOf('UI Element') >= 0) {
......@@ -347,8 +348,8 @@ function fetch_ui_regions(target,dimensions,metrics,filters,shared,resultPositio
}
// save the data
analyticsResults[resultPosition]['clicks'].content = totalContentClicks;
analyticsResults[resultPosition]['clicks'].siteNav = totalSiteNavClicks;
analyticsResults[resultPosition]['clicks'].content = totalContentClicks;
analyticsResults[resultPosition]['clicks'].siteNav = totalSiteNavClicks;
var engagementPercent = Math.floor(totalContentClicks / (totalContentClicks+Math.floor(analyticsResults[resultPosition].pageViews)) * 1000) / 10; // the number of unique content clicks vs unique page views
......@@ -380,8 +381,10 @@ function fetch_page_time(target,dimensions,metrics,filters,shared,resultPosition
});
Promise.all([localQuery]).then(function(results) {
$(target + ' td.tr-time-on-page').html(''); //empty
// save the data
analyticsResults[resultPosition].pageTime = results[0].rows[0][1];
analyticsResults[resultPosition].pageTime = results[0].rows[0][1];
var timeOnPage = Math.round((analyticsResults[resultPosition].pageTime / 60) * 100) / 100;
// meets the pageviews target?
......@@ -389,7 +392,7 @@ function fetch_page_time(target,dimensions,metrics,filters,shared,resultPosition
if (timeOnPage < 2) {
success = iconWarning;
} else if (timeOnPage < 3) {
success = iconSoSo;
success = iconSoSo;
}
$(target + ' td.tr-time-on-page').append('' +success + timeOnPage);
......@@ -411,15 +414,17 @@ function fetch_leave_rate(target,dimensions,metrics,filters,shared,resultPositio
});
Promise.all([localQuery]).then(function(results) {
$(target + ' td.tr-leave-rate').html(''); //empty
// save the data
analyticsResults[resultPosition].bounceRate = results[0].rows[0][1];
analyticsResults[resultPosition].bounceRate = results[0].rows[0][1];
// meets the pageviews target?
var success = iconSuccess;
if (analyticsResults[resultPosition].bounceRate > 80) {
success = iconWarning;
} else if (analyticsResults[resultPosition].bounceRate > 60) {
success = iconSoSo;
success = iconSoSo;
}
var leavePercent = Math.round((analyticsResults[resultPosition].bounceRate) * 100) / 100;
......
......@@ -37,60 +37,20 @@
<h2>EMBL News weekly dashbaord</h2>
<section>
<nav aria-label="You are here:" role="navigation">
<ul class="breadcrumbs">
<li><a href="//github.com/ebiwd/analytics-dashboards">EMBL-EBI Analytics dashboards</a></li>
<!-- <li class="disabled">Disabled</li> -->
<li>
<span class="show-for-sr">Current: </span> EMBL News weekly dashbaord
</li>
</ul>
</nav>
<nav aria-label="You are here:" role="navigation">
<ul class="breadcrumbs">
<li><a href="//github.com/ebiwd/analytics-dashboards">EMBL-EBI Analytics dashboards</a></li>
<!-- <li class="disabled">Disabled</li> -->
<li>
<span class="show-for-sr">Current: </span> EMBL News weekly dashbaord
</li>
</ul>
</nav>
<div class="row" id="main-content-area">
<div class="" id="main-content-area">
<ul class="accordion" data-accordion data-multi-expand="true">
<li class="accordion-item" data-accordion-item>
<a href="#" class="accordion-title">Conceptual change list</a>
<div class="accordion-content" data-tab-content>
<ul>
<li>JS link/event tracking</li>
<ul>
<li>Add ratio of clicks on content to overall page views</li>
<li>Additional metrics and info might come in handy, such as pages (on the EMBL websites) visited from this page, searches performed, other actions taken (e.g. share button clicked, newsletter subscription etc.).</li>
</ul>
<li>Perhaps we should add desktop vs mobile stats per article?</li>
</ul>
</div>
</li> <li class="accordion-item" data-accordion-item>
<a href="#" class="accordion-title">Polishing list</a>
<div class="accordion-content" data-tab-content>
<ul>
<li>Referers: Aggregate stats</li>
<li>And I’m wondering whether we should have a line in the chart pointing to an average traffic..or the green/orange/red indicator showing how the number of views relate to the average article... Like the idea of various “averages”. Instinct suggest that metric should come from a human — if you will: targets for news stories for # of visits, bounce rate, time on page, etc.</li>
<li>Lock date selector to weeks</li>
<li>Dev tasks</li>
<ul>
<li>Optimise code structure</li>
<li>Expose somewhere for others to access. gh-pages? (users will still need to login to GA)</li>
</ul>
</ul>
</div>
</li>
<li class="accordion-item is-active" data-accordion-item>
<a href="#" class="accordion-title">Options</a>
<div class="accordion-content" data-tab-content>
<label for="originDate">Pick an end date for the week's report</label>
<p class="small">Note, the report period will round to weekly units. Format is DD-MM-YYYY.</p>
<input id="originDate" type="date" value=""/>
</div>
</li>
</ul>
<div class="tools"></div>
<!-- Via: https://ga-dev-tools.appspot.com/embed-api/third-party-visualizations/ -->
......@@ -103,7 +63,7 @@
}
table tbody td {
vertical-align: top;
}
}
.icon-indicator {
font-size: 1.5rem;
}
......@@ -112,15 +72,30 @@
<!-- Add HTML containers to host the dashboard components. -->
<div>
<pre><div id="embed-api-auth-container"></div></pre>
<!-- <div id="view-selector-container"></div> -->
<div id="view-name"></div>
<div id="active-users-container"></div>
<h3>Options</h3>
<div class="row">
<div class="columns medium-3">
<pre><div id="embed-api-auth-container"></div></pre>
<!-- <div id="view-selector-container"></div> -->
<div id="view-name"></div>
<div id="active-users-container"></div>
</div>
<div class="columns medium-2">
<div class="tools"></div>
</div>
<div class="columns medium-7">
<label for="originDate">Pick an end date for the week's report</label>
<p class="small">Note, the report period will round to weekly units. Format is DD-MM-YYYY.</p>
<input id="originDate" type="date" value=""/>
</div>
</div>
<h2 class="local-title">Loading...</h2>
<cite class="local-description"></cite>
<p class="local-description">
If you have yet to authenticate through this webpage, you need to click the orange button above. (Note: you also need to be able ot access the EMBL Google Analytics account. If you're not sure, <a href="https://analytics.google.com/analytics/web/#embed/report-home/a21480202w75912813p78446688/">try this link</a>.)
</p>
<div class="Chartjs">
<div class="label"></div>
......@@ -163,6 +138,39 @@
<div class="referer-test"></div>
<ul class="accordion" data-accordion data-multi-expand="true">
<li class="accordion-item is-active" data-accordion-item>
<a href="#" class="accordion-title">Conceptual change list</a>
<div class="accordion-content" data-tab-content>
<ul>
<li>JS link/event tracking</li>
<ul>
<li>Add ratio of clicks on content to overall page views</li>
<li>Additional metrics and info might come in handy, such as pages (on the EMBL websites) visited from this page, searches performed, other actions taken (e.g. share button clicked, newsletter subscription etc.).</li>
</ul>
<li>Perhaps we should add desktop vs mobile stats per article?</li>
</ul>
</div>
</li> <li class="accordion-item" data-accordion-item>
<a href="#" class="accordion-title">Polishing list</a>
<div class="accordion-content" data-tab-content>
<ul>
<li>Referers: Aggregate stats</li>
<li>And I’m wondering whether we should have a line in the chart pointing to an average traffic..or the green/orange/red indicator showing how the number of views relate to the average article... Like the idea of various “averages”. Instinct suggest that metric should come from a human — if you will: targets for news stories for # of visits, bounce rate, time on page, etc.</li>
<li>Lock date selector to weeks</li>
<li>Dev tasks</li>
<ul>
<li>Optimise code structure</li>
<li>Expose somewhere for others to access. gh-pages? (users will still need to login to GA)</li>
</ul>
</ul>
</div>
</li>
</ul>
</div>
</section>
</div><!-- /.container -->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment