include URL & title in tracking request

This commit is contained in:
Danny van Kooten 2016-12-08 13:09:21 +01:00
parent dabb89e863
commit 7d55a7b25a
4 changed files with 17 additions and 5 deletions

View File

@ -12,7 +12,6 @@ This is a general draft document for thoughts and todo's, without any structure
- Bulk process tracking requests (Redis or in-memory?) - Bulk process tracking requests (Redis or in-memory?)
- Allow sorting in table overviews. - Allow sorting in table overviews.
- Choose a OS license & settle on name. - Choose a OS license & settle on name.
- JS client for consuming API endpoints.
- Envelope API responses & perhaps return total in table overview? - Envelope API responses & perhaps return total in table overview?
- Track canonical URL's. - Track canonical URL's.
- Show referrals. - Show referrals.

View File

@ -5,8 +5,7 @@ import Client from '../lib/client.js';
import * as numbers from '../lib/numbers.js'; import * as numbers from '../lib/numbers.js';
import * as d3 from 'd3'; import * as d3 from 'd3';
import tip from 'd3-tip'; d3.tip = require('d3-tip');
d3.tip = tip;
const dayInSeconds = 60 * 60 * 24; const dayInSeconds = 60 * 60 * 24;

View File

@ -28,13 +28,23 @@ function setTrackerUrl(v) {
} }
function trackPageview() { function trackPageview() {
// Respect "Do Not Track" requests
if( navigator.DonotTrack == 1 ) { if( navigator.DonotTrack == 1 ) {
return; return;
} }
// get the path or canonical
var path = location.pathname + location.search;
var canonical = document.querySelector('link[rel="canonical"]');
if(canonical && canonical.href) {
path = canonical.href.substring(canonical.href.indexOf('/', 7)) || '/';
}
var d = { var d = {
h: location.hostname,
t: document.title,
l: navigator.language, l: navigator.language,
p: location.pathname + location.search, p: path,
sr: screen.width + "x" + screen.height, sr: screen.width + "x" + screen.height,
t: document.title, t: document.title,
r: document.referrer r: document.referrer
@ -53,4 +63,6 @@ window.ana = function() {
}; };
// process existing queue // process existing queue
queue.map((i) => ana.apply(this, i)); queue.forEach(function(i) {
ana.apply(this, i);
});

View File

@ -30,6 +30,8 @@ gulp.task('browserify', function () {
}); });
gulp.task('minify', function(cb) { gulp.task('minify', function(cb) {
process.env.NODE_ENV = 'production';
pump([ pump([
gulp.src('./static/js/*.js'), gulp.src('./static/js/*.js'),
uglify().on('error', gutil.log), uglify().on('error', gutil.log),