Skip to content

Commit

Permalink
[#2375] Tracking (internal) now uses fanstatic
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Sep 5, 2012
1 parent 2968f8e commit b9a9006
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 26 deletions.
1 change: 1 addition & 0 deletions ckan/public/base/javascript/resource.config
@@ -1,6 +1,7 @@
[depends]

main = vendor/jquery.js
tracking.js = vendor/jquery.js

[custom render order]

Expand Down
22 changes: 22 additions & 0 deletions ckan/public/base/javascript/tracking.js
@@ -0,0 +1,22 @@
$(function (){
// Tracking
var url = location.pathname;
// remove any site root from url
console.log($('body').data('site-root'));
url = url.substring($('body').data('locale-root'), url.length);
// trim any trailing /
url = url.replace(/\/*$/, '');
$.ajax({url : $('body').data('site-root') + '_tracking',
type : 'POST',
data : {url:url, type:'page'},
timeout : 300 });
$('a.resource-url-analytics').click(function (e){
var url = $(e.target).closest('a').attr('href');
$.ajax({url : $('body').data('site-root') + '_tracking',
data : {url:url, type:'resource'},
type : 'POST',
complete : function () {location.href = url;},
timeout : 30});
e.preventDefault();
});
});
3 changes: 1 addition & 2 deletions ckan/templates/page.html
Expand Up @@ -96,9 +96,8 @@ <h2>A sidebar item</h2>

{%- block scripts %}
{% resource 'base/main' %}

{% if config.get('ckan.tracking_enabled', 'false') %}
{% snippet 'snippets/internal_tracking.html' %}
{% resource 'base/tracking.js' %}
{% endif %}
{{ super() }}
{% endblock -%}
24 changes: 0 additions & 24 deletions ckan/templates/snippets/internal_tracking.html

This file was deleted.

0 comments on commit b9a9006

Please sign in to comment.