diff --git a/ckanext/googleanalytics/fanstatic_library/googleanalytics_event_tracking.js b/ckanext/googleanalytics/fanstatic_library/googleanalytics_event_tracking.js index a6c9f35..322463c 100644 --- a/ckanext/googleanalytics/fanstatic_library/googleanalytics_event_tracking.js +++ b/ckanext/googleanalytics/fanstatic_library/googleanalytics_event_tracking.js @@ -5,10 +5,12 @@ this.ckan.module('google-analytics', function(jQuery, _) { googleanalytics_resource_prefix: '' }, initialize: function() { - resource_prefix = this.options.googleanalytics_resource_prefix; - jQuery('a.resource-url-analytics').on('click', function(){ - resource_url = resource_prefix + encodeURIComponent(this.href); - _gaq.push(['_trackPageview', resource_url]); + jQuery('a.resource-url-analytics').on('click', function() { + var resource_prefix = this.options.googleanalytics_resource_prefix; + var resource_url = resource_prefix + encodeURIComponent(jQuery(this).prop('href')); + if (resource_url) { + _gaq.push(['_trackPageview', resource_url]); + } }); } } diff --git a/ckanext/googleanalytics/plugin.py b/ckanext/googleanalytics/plugin.py index 910a8a1..11bb893 100644 --- a/ckanext/googleanalytics/plugin.py +++ b/ckanext/googleanalytics/plugin.py @@ -52,7 +52,8 @@ class GoogleAnalyticsPlugin(p.SingletonPlugin): self.track_events = converters.asbool( config.get('googleanalytics.track_events', False)) - p.toolkit.add_resource('fanstatic_library', 'ckanext-googleanalytics') + if not converters.asbool(config.get('ckan.legacy_templates', 'false')): + p.toolkit.add_resource('fanstatic_library', 'ckanext-googleanalytics') def update_config(self, config): '''Change the CKAN (Pylons) environment configuration.