File tree Expand file tree Collapse file tree 4 files changed +42
-1
lines changed
Expand file tree Collapse file tree 4 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,11 @@ def index():
204204 else :
205205 lastDiscoveries = []
206206
207+ if current_app .config ["MATOMO_URL" ] != "" :
208+ matomo_script = current_app .config ["MATOMO_SCRIPT" ]
209+ else :
210+ matomo_script = ""
211+
207212 connection .close ()
208213 session .close ()
209214
@@ -213,6 +218,7 @@ def index():
213218 mostViewTaxon = mostViewTaxon ,
214219 customStatMedias = customStatMedias ,
215220 lastDiscoveries = lastDiscoveries ,
221+ matomo_script = matomo_script ,
216222 )
217223
218224
Original file line number Diff line number Diff line change @@ -87,6 +87,11 @@ LANGUAGES = {
8787# Code de suivi des statistiques Google Analytics (si AFFICHAGE_FOOTER = True)
8888ID_GOOGLE_ANALYTICS = "UA-xxxxxxx-xx"
8989
90+ # Suivi de statistiques avec MATOMO si MATOMO_URL != ""
91+ MATOMO_URL = "" # URL lié à votre MATOMO
92+ MATOMO_SITE_ID = 1 # id du site suivi qui correspond ici à celui du GeoNature Atlas (votre site doit être renseigné dans MATOMO)
93+ #### LIEN AIDE MATOMO : https://developer.matomo.org/guides/tracking-javascript-guide
94+
9095# Utiliser et afficher le glossaire (static/custom/glossaire.json.sample)
9196GLOSSAIRE = False
9297
Original file line number Diff line number Diff line change 7777 },
7878}
7979
80+ # LATEST VERSION OF MATOMO
81+ MATOMO_SCRIPT_TO_INCLUDE = """
82+ var _paq = _paq || [];
83+ var _paq = window._paq = window._paq || [];
84+ _paq.push(['trackPageView']);
85+ _paq.push(['enableLinkTracking']);
86+ (function() {
87+ var u="//url_matomo/";
88+ _paq.push(['setTrackerUrl', u+'matomo.php']);
89+ _paq.push(['setSiteId', site_id]);
90+ var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
91+ g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
92+ })();
93+ """
94+
8095
8196class SecretSchemaConf (Schema ):
8297 class Meta :
@@ -208,7 +223,9 @@ class Meta:
208223 # (no need to restart the atlas service when updating templates)
209224 # Defaults to False to have the best performance in production
210225 TEMPLATES_AUTO_RELOAD = fields .Boolean (load_default = False )
211-
226+ MATOMO_SCRIPT = fields .String (load_default = MATOMO_SCRIPT_TO_INCLUDE )
227+ MATOMO_URL = fields .String (load_default = "" )
228+ MATOMO_SITE_ID = fields .Integer (load_default = 0 )
212229 @validates_schema
213230 def validate_url_taxhub (self , data , ** kwargs ):
214231 """
Original file line number Diff line number Diff line change 1515 {% endblock %}
1616 < link rel ="stylesheet " href ="{{ url_for('static', filename='custom/custom.css') }} "/>
1717 {% block metaTags %}{% endblock %}
18+
19+ {% if configuration.MATOMO_URL and configuration.MATOMO_SITE_ID is defined %}
20+ {% set site_id = configuration.MATOMO_SITE_ID | int(default=-1) %}
21+ {% set url_matomo = configuration.MATOMO_URL %}
22+ <!-- Matomo -->
23+ < script type ="text/javascript ">
24+ var url_matomo = "{{ url_matomo }}" ;
25+ var site_id = { { site_id | int } } ;
26+ { { matomo_script | safe } }
27+ </ script >
28+ <!-- End Matomo Code -->
29+ {% endif %}
30+
1831</ head >
1932
2033< body >
You can’t perform that action at this time.
0 commit comments