From 924bc71a33dce4e846df9ce77f1ba1036f9dc788 Mon Sep 17 00:00:00 2001 From: Sergey Motornyuk Date: Tue, 17 Jan 2023 21:19:39 +0200 Subject: [PATCH] fix: adapt event_tracking.js to gtag` --- .../assets/googleanalytics_event_tracking.js | 10 +++++++++- setup.cfg | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ckanext/googleanalytics/assets/googleanalytics_event_tracking.js b/ckanext/googleanalytics/assets/googleanalytics_event_tracking.js index d2a7c77..b7a8b57 100644 --- a/ckanext/googleanalytics/assets/googleanalytics_event_tracking.js +++ b/ckanext/googleanalytics/assets/googleanalytics_event_tracking.js @@ -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); + } + } }); } diff --git a/setup.cfg b/setup.cfg index 9705d99..213a746 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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