File tree 4 files changed +44
-1
lines changed
4 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,13 @@ def index():
204
204
else :
205
205
lastDiscoveries = []
206
206
207
+ if current_app .config ["MATOMO_URL" ] != "" :
208
+ matomo_script = current_app .config ["MATOMO_SCRIPT" ]
209
+ else :
210
+ matomo_script = ""
211
+
212
+
213
+
207
214
connection .close ()
208
215
session .close ()
209
216
@@ -213,6 +220,7 @@ def index():
213
220
mostViewTaxon = mostViewTaxon ,
214
221
customStatMedias = customStatMedias ,
215
222
lastDiscoveries = lastDiscoveries ,
223
+ matomo_script = matomo_script ,
216
224
)
217
225
218
226
Original file line number Diff line number Diff line change @@ -87,6 +87,11 @@ LANGUAGES = {
87
87
# Code de suivi des statistiques Google Analytics (si AFFICHAGE_FOOTER = True)
88
88
ID_GOOGLE_ANALYTICS = "UA-xxxxxxx-xx"
89
89
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
+
90
95
# Utiliser et afficher le glossaire (static/custom/glossaire.json.sample)
91
96
GLOSSAIRE = False
92
97
Original file line number Diff line number Diff line change 77
77
},
78
78
}
79
79
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
+
80
95
81
96
class SecretSchemaConf (Schema ):
82
97
class Meta :
@@ -208,7 +223,9 @@ class Meta:
208
223
# (no need to restart the atlas service when updating templates)
209
224
# Defaults to False to have the best performance in production
210
225
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 )
212
229
@validates_schema
213
230
def validate_url_taxhub (self , data , ** kwargs ):
214
231
"""
Original file line number Diff line number Diff line change 15
15
{% endblock %}
16
16
< link rel ="stylesheet " href ="{{ url_for('static', filename='custom/custom.css') }} "/>
17
17
{% 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
+
18
31
</ head >
19
32
20
33
< body >
You can’t perform that action at this time.
0 commit comments