diff --git a/CHANGELOG.md b/CHANGELOG.md index cd59e4efe8ae36d2df44687fe54897f1dcc0a25a..00c24deee90d8f2417a8d53671b162c71fb659aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - This update requires changes to your `production.ini` file: Beaker keys have been removed. Use SECRET_KEY, etc. +## [2.4.7] - 2025-01-20 + +### Added + +- Added Matomo support to enable tracking and analytics. The following configuration variables were introduced: + - `ckanext.odsh.matomo_enabled` (boolean): Enables or disables Matomo tracking. Default is `False`. + - `ckanext.odsh.matomo_base_uri` (string): Specifies the base URI of the Matomo tracker. Default is `None`. + - `ckanext.odsh.matomo_site_id` (string): Specifies the Matomo site ID for the instance. Default is `None`. + ## [2.4.6] - 2025-01-09 ### Added diff --git a/README.md b/README.md index 66ec9eed037341522588916fdaa46bd411f1ae98..19b10191173cc5bf869b46561d4ddb9a2e5aef54 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,9 @@ Parameter | Type | Default | Description `ckanext.odsh.lenient_with` | `string` | Empty string | Comma seperated list of organization IDs for which certain validations should be more lenient, e.g., `09871195-cd0a-4767-9396-276404c940d9,6389d8d9-4eed-472f-9220-4cc2dd82fb90`. `ckanext.odsh.testuser` | `string` | `None` | Name of user for testing. `ckanext.odsh.testuserpass` | `string` | `None` | Password of user for testing. +`ckanext.odsh.matomo_enabled` | `boolean` | `False` | Enable Matomo tracking. +`ckanext.odsh.matomo_base_uri` | `string` | `None` | Matomo tracker base URI. +`ckanext.odsh.matomo_site_id` | `string` | `None` | Matomo site id. Additionaly you might want to set the following configuration parameters: diff --git a/ckanext/odsh/helpers.py b/ckanext/odsh/helpers.py index bc8dea9ec0811b83eb85dafa8074cf77cb597858..9c6ba27837703bb2b625c3bd1cce885ca8e6f952 100644 --- a/ckanext/odsh/helpers.py +++ b/ckanext/odsh/helpers.py @@ -848,3 +848,12 @@ def extract_email(text): # If there are matches, return the first email address found, else return None return matches[0] if matches else None + +def odsh_matomo_enabled(): + return config.get('ckanext.odsh.matomo_enabled', False) == 'True' + +def odsh_matomo_base_uri(): + return config.get('ckanext.odsh.matomo_base_uri', None) + +def odsh_matomo_site_id(): + return config.get('ckanext.odsh.matomo_site_id', None) \ No newline at end of file diff --git a/ckanext/odsh/i18n/ckanext-odsh.pot b/ckanext/odsh/i18n/ckanext-odsh.pot index b5c63ccda9b1eb15933ff9c6c31ac434f0e3e158..7a8a2e53c4825158897691c178d8b59728285102 100644 --- a/ckanext/odsh/i18n/ckanext-odsh.pot +++ b/ckanext/odsh/i18n/ckanext-odsh.pot @@ -6,7 +6,7 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: ckanext-odsh 2.4.6\n" +"Project-Id-Version: ckanext-odsh 2.4.7\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "POT-Creation-Date: 2024-09-20 11:17+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" diff --git a/ckanext/odsh/plugin.py b/ckanext/odsh/plugin.py index c368451ebcf95c187952a87f1a9b01492032f75e..1b4845c67454e42654639acdec3c3828f38e1cd5 100644 --- a/ckanext/odsh/plugin.py +++ b/ckanext/odsh/plugin.py @@ -325,6 +325,9 @@ class OdshPlugin(p.SingletonPlugin, DefaultTranslation, tk.DefaultDatasetForm): 'odsh_load_mdk_sample_dataset': helpers_odsh.odsh_load_mdk_sample_dataset, 'odsh_load_raw_mdk_sample_dataset': helpers_odsh.odsh_load_raw_mdk_sample_dataset, 'format_resource_format': helpers_odsh.format_resource_format, + 'odsh_matomo_enabled': helpers_odsh.odsh_show_testbanner, + 'odsh_matomo_base_uri': helpers_odsh.odsh_matomo_base_uri, + 'odsh_matomo_site_id': helpers_odsh.odsh_matomo_site_id, } diff --git a/ckanext/odsh/templates/base.html b/ckanext/odsh/templates/base.html index fdc7cbe465311eb0508c71e8c0f79fb684fec1ee..57b96682a79878fe39313a1f15a757ae1364642f 100644 --- a/ckanext/odsh/templates/base.html +++ b/ckanext/odsh/templates/base.html @@ -10,6 +10,32 @@ {% block head_extras %} {{ super() }} + {% if h.odsh_matomo_enabled() %} + <!-- Matomo --> + <script> + var _paq = window._paq = window._paq || []; + /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ + _paq.push(["disableCookies"]); + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + (function() { + var u="{{ h.odsh_matomo_base_uri() | escape }}"; + _paq.push(['setTrackerUrl', u + 'matomo.php']); + _paq.push(['setSiteId', '{{ h.odsh_matomo_site_id() | escape }}']); + var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0]; + g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s); + })(); + </script> + <noscript> + <p> + <img referrerpolicy="no-referrer-when-downgrade" + src="{{ h.odsh_matomo_base_uri() | escape }}matomo.php?idsite={{ h.odsh_matomo_site_id() | escape }}&rec=1" + style="border:0;" + alt="" /> + </p> + </noscript> + <!-- End Matomo Code --> + {% endif %} {% endblock %} {% block bodytag %} data-site-root="{{ h.odsh_public_url() }}" data-locale-root="{{ h.odsh_public_url() }}" {% endblock %} diff --git a/setup.py b/setup.py index acaf42743adb43394479661db940b2cafebc93c2..545bc06b5ea6f496f1c42502fb37c9e87afb5ee8 100755 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ setup( # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # http://packaging.python.org/en/latest/tutorial.html#version - version='2.4.6', + version='2.4.7', description='''A general extension for CKAN that is used for the Open Data Schleswig-Holstein project''', long_description=long_description,