Commits

Nick Freear  committed efa04cc

Numerous small fixes/ mods. to capret-piwik Javascript..

* Appending '/ CaPReT' on the Piwik action_name,
* @data-piwik-src-ref <script> attribute - switch...
* ..Switch - put 'source' URL in Piwik's 'urlref' parameter (default, 1)..
* ..Or, put source URL in Piwik 'url' parameter (0)
* Also, put source URL in '_cvar'[1] - custom variables
...

  • Participants
  • Parent commits 471e7f6

Comments (0)

Files changed (1)

File application/assets/capret/js/capret-piwik.js

 (function( jQuery ){
 	jQuery = jQuery.noConflict(true);
 	var
-	  piwik_url = get_data('url', 'http://track.olnet.org/piwik/')
+	  piwik_url = get_data('url', 'http://track.olnet.org/piwik')
 	, idsite = get_data('idsite', 1)
+	, source_ref = get_data('src-ref', true)
 	, record = get_data('rec', 1)
 	, debug = get_data('debug', false)
 	// Aliases
 		env.idsite = idsite;
 		env.rec = record;
 		env.rand = M.floor(M.random()*100);
-		env.action_name = Enc(doc.title) +'/'+ Enc(' '+tx); //+'"';
+		env.action_name = Enc(doc.title) +'/'+ Enc(' '+tx) +'/'+Enc(' CaPReT'); //+'"';
 
 		//Custom variable JSON (last, in case it is stripped on paste?)
 		env._cvar = {
-			'1': ['via', 'CaPReT'],
+			//'1': ['via', 'CaPReT'],
+			'1': ['source', doc.location.href],
 			'2': ['length', copy_text.length], //'len'
 			'3': ['text', tx], //'txt'
 			'4': ['modified', doc.lastModified], //'lmod'
 		return jQuery.param(env);
 	}
 	function image_tag_piwik(copy_text, env){
-		img = '<img src="'+ piwik_url +'piwik.php?' + final_params_pi(copy_text, env) + '"/>';
+		img = '<img src="'+ piwik_url +'/piwik.php?' + final_params_pi(copy_text, env) + '"/>';
 		if (debug) {
 			console.log(img);
 			console.log(env);
 		return img;
 	}
 	jQuery(function() {
-		var env = {};
-		env.url = Enc(doc.location.href);
+		var env = {}
+		, urlkey = source_ref ? 'urlref' : 'url'
+		;
+		env[urlkey] = Enc(doc.location.href); //Use 'ContentReuse' Piwik plugin.
 		env.res = Enc(win.innerWidth +'x'+ win.innerHeight);
 		//env.id = make_id();
 		var license = license_parser.get_license();