From df3f575119dd619e1e82b1c1d67541cbac334e57 Mon Sep 17 00:00:00 2001 From: John Glover Date: Mon, 23 Jul 2012 11:48:59 +0100 Subject: [PATCH] Add remaining track events. --- .../public/scripts/ckanext-googleanalytics.js | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/ckanext/googleanalytics/public/scripts/ckanext-googleanalytics.js b/ckanext/googleanalytics/public/scripts/ckanext-googleanalytics.js index bdbdcdc..8e9047d 100644 --- a/ckanext/googleanalytics/public/scripts/ckanext-googleanalytics.js +++ b/ckanext/googleanalytics/public/scripts/ckanext-googleanalytics.js @@ -2,8 +2,6 @@ $(document).ready(function () { // Google Analytics event tracking - // alert($(this).attr('href')); - // group links on home page $('body.home div.group a').click(function() { _gaq.push(['_trackEvent', 'Home', 'Click: Group Link', $(this).attr('href')]); @@ -31,6 +29,20 @@ _gaq.push(['_trackEvent', 'User', 'Click: Dataset Link', $(this).attr('href')]); }); + // Compare Button on /dataset/history/X + $('body.package.history form#dataset-revisions input[name="diff"]').click(function() { + _gaq.push(['_trackEvent', 'Dataset', 'Click: Button', 'Compare History']); + }); + + // Tags on right hand sidebar of /dataset/X + $('body.package.read div#sidebar h3') + .filter(function(index) {return $(this).text().indexOf("Tags") != -1;}) + .next('ul') + .find('a') + .click(function() { + _gaq.push(['_trackEvent', 'Dataset', 'Click: Tag', $(this).attr('href')]); + }); + // Any of the group links on /group $('body.group.index table.groups a').click(function() { _gaq.push(['_trackEvent', 'Group', 'Click: Group Link', $(this).attr('href')]); @@ -38,7 +50,7 @@ // Clicking any of the right hand sidebar tags on /group/X $('body.group.read div#sidebar h2') - .filter(function(index) {return $(this).text() === "Tags";}) + .filter(function(index) {return $(this).text().indexOf("Tags") != -1;}) .next('ul') .find('a') .click(function() { @@ -46,10 +58,15 @@ }); // Visiting /group/history/X + $('body.group div#minornavigation ul.nav a') + .filter(function(index) {return $(this).text().indexOf("History") != -1;}) + .click(function() { + _gaq.push(['_trackEvent', 'Group', 'Click: History Tab', $(this).attr('href')]); + }); + // Compare Button on /group/history/X - // Compare Button on /dataset/history/X - // Tags on right hand sidebar of /dataset/X - // Download button on any /dataset/X/resource[> page - // Data API button on any /dataset/X/resource[> page + $('body.group.history form#group-revisions input[name="diff"]').click(function() { + _gaq.push(['_trackEvent', 'Group', 'Click: Button', 'Compare History']); + }); }); }(jQuery));