Skip to content
Snippets Groups Projects
Commit 106be9ad authored by Jesper Zedlitz's avatar Jesper Zedlitz
Browse files

Merge branch '74-matomo-support' into 'master'

Resolve "Matomo Support"

Closes #74

See merge request !54
parents caf32d75 c212941f
Branches
Tags
1 merge request!54Resolve "Matomo Support"
......@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### 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
......
......@@ -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:
......
......@@ -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
......@@ -359,6 +359,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,
}
......
......@@ -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 }}&amp;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 %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment