Tweaks to google analytics CKAN 2.0 JS module
1. Specified `resource_prefix` and `resource_url` context more tightly (could be global context) 2. Changed `this.href` to `jQuery(this).prop('href')` as it will never throw a syntax error when upon the condition of a `a.resource-url-analytics` not having a `href` attribute 3. Also added check so that if no `href` is present it doesn't send a blank link to google analytics
This commit is contained in:
parent
e6bf938054
commit
f254d1afd7
|
@ -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]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue