Skip to content
Snippets Groups Projects
Verified Commit 0149f68f authored by Thorge Petersen's avatar Thorge Petersen
Browse files

feat: readded matomo support

parent caf32d75
Branches
Tags
1 merge request!54Resolve "Matomo Support"
...@@ -100,6 +100,9 @@ Parameter | Type | Default | Description ...@@ -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.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.testuser` | `string` | `None` | Name of user for testing.
`ckanext.odsh.testuserpass` | `string` | `None` | Password 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: Additionaly you might want to set the following configuration parameters:
......
...@@ -848,3 +848,12 @@ def extract_email(text): ...@@ -848,3 +848,12 @@ def extract_email(text):
# If there are matches, return the first email address found, else return None # If there are matches, return the first email address found, else return None
return matches[0] if matches else 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): ...@@ -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_mdk_sample_dataset': helpers_odsh.odsh_load_mdk_sample_dataset,
'odsh_load_raw_mdk_sample_dataset': helpers_odsh.odsh_load_raw_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, '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 @@ ...@@ -10,6 +10,32 @@
{% block head_extras %} {% block head_extras %}
{{ super() }} {{ 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 %} {% endblock %}
{% block bodytag %} data-site-root="{{ h.odsh_public_url() }}" data-locale-root="{{ h.odsh_public_url() }}" {% 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