fix: adapt event_tracking.js to gtag`

This commit is contained in:
Sergey Motornyuk 2023-01-17 21:19:39 +02:00
parent d085a7d5c2
commit 924bc71a33
2 changed files with 10 additions and 2 deletions

View File

@ -11,7 +11,15 @@ ckan.module("google-analytics", function(jQuery, _) {
var resource_url = encodeURIComponent(jQuery(this).prop("href"));
if (resource_url) {
ga("send", "event", "Resource", "Download", resource_url);
if (typeof ga === "undefined") {
gtag('event', "Download", {
'event_category': "Resource",
'event_label': resource_url,
});
} else {
ga("send", "event", "Resource", "Download", resource_url);
}
}
});
}

View File

@ -1,6 +1,6 @@
[metadata]
name = ckanext-googleanalytics
version = 2.2.0
version = 2.2.1
description = Add GA tracking and reporting to CKAN instance
long_description = file: README.md
long_description_content_type = text/markdown