Merge pull request #3413 from alchemy-fr/PHRAS-2997-Add_Matomo_analytic_service

PHRAS-2997 #comment merge of Matomo analytic service in Phraseanet core
This commit is contained in:
Nicolas Maillat
2020-03-26 20:32:35 +01:00
committed by GitHub
11 changed files with 52 additions and 0 deletions

0
cache/.gitkeep vendored
View File

View File

@@ -102,6 +102,8 @@ class RegistryFormManipulator
'keywords' => null, 'keywords' => null,
'description' => null, 'description' => null,
'analytics' => null, 'analytics' => null,
'matomo-analytics-url' => null,
'matomo-analytics-id' => null,
'allow-indexation' => true, 'allow-indexation' => true,
'home-presentation-mode' => 'GALLERIA', 'home-presentation-mode' => 'GALLERIA',
'default-subdef-url-ttl' => 7200, 'default-subdef-url-ttl' => 7200,

View File

@@ -38,6 +38,12 @@ class GeneralFormType extends AbstractType
$builder->add('analytics', 'text', [ $builder->add('analytics', 'text', [
'label' => 'Google Analytics identifier', 'label' => 'Google Analytics identifier',
]); ]);
$builder->add('matomo-analytics-url', 'text', [
'label' => 'Matomo Analytics url',
]);
$builder->add('matomo-analytics-id', 'text', [
'label' => 'Matomo Analytics identifier',
]);
$builder->add('allow-indexation', 'checkbox', [ $builder->add('allow-indexation', 'checkbox', [
'label' => 'Allow the website to be indexed by search engines like Google', 'label' => 'Allow the website to be indexed by search engines like Google',
]); ]);

View File

@@ -84,5 +84,7 @@ define('GV_homeTitle', 'SuperPhraseanet');
define('GV_metaKeywords', ''); define('GV_metaKeywords', '');
define('GV_metaDescription', ''); define('GV_metaDescription', '');
define('GV_googleAnalytics', ''); define('GV_googleAnalytics', '');
define('GV_matomoAnalyticsUrl', '');
define('GV_matomoAnalyticsId', '');
define('GV_allow_search_engine', true); define('GV_allow_search_engine', true);
define('GV_display_gcf', true); define('GV_display_gcf', true);

View File

@@ -24,5 +24,6 @@
<body> <body>
{% block content %}{% endblock %} {% block content %}{% endblock %}
{% include 'common/analytics.html.twig' %} {% include 'common/analytics.html.twig' %}
{% include 'common/matomo_analytics.html.twig' %}
</body> </body>
</html> </html>

View File

@@ -0,0 +1,18 @@
{% if app['conf'].get(['registry', 'general', 'matomo-analytics-url']) != '' %}
{% if app['conf'].get(['registry', 'general', 'matomo-analytics-id']) != '' %}
<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//{{ app['conf'].get(['registry', 'general', 'matomo-analytics-url']) }}/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', {{ app['conf'].get(['registry', 'general', 'matomo-analytics-id']) }}]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
{% endif %}
{% endif %}

View File

@@ -42,5 +42,6 @@
{% block extra_content %}{% endblock %} {% block extra_content %}{% endblock %}
{% block bodyJavascript %}{% endblock %} {% block bodyJavascript %}{% endblock %}
{% include 'common/analytics.html.twig' %} {% include 'common/analytics.html.twig' %}
{% include 'common/matomo_analytics.html.twig' %}
</body> </body>
</html> </html>

View File

@@ -25,5 +25,6 @@
</div> </div>
</div> </div>
{% include 'common/analytics.html.twig' %} {% include 'common/analytics.html.twig' %}
{% include 'common/matomo_analytics.html.twig' %}
</body> </body>
</html> </html>

View File

@@ -0,0 +1,18 @@
{% if app['conf'].get(['registry', 'general', 'matomo-analytics-url']) != '' %}
{% if app['conf'].get(['registry', 'general', 'matomo-analytics-id']) != '' %}
<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="{{ app['conf'].get(['registry', 'general', 'matomo-analytics-url']) }}/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', {{ app['conf'].get(['registry', 'general', 'matomo-analytics-id']) }}]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
{% endif %}
{% endif %}

View File

@@ -100,6 +100,7 @@
{% endblock %} {% endblock %}
{% block analytics %} {% block analytics %}
{% include 'common/analytics.html.twig' %} {% include 'common/analytics.html.twig' %}
{% include 'common/matomo_analytics.html.twig' %}
{% endblock analytics %} {% endblock analytics %}
{% block scripts %}{% endblock scripts %} {% block scripts %}{% endblock scripts %}

View File

@@ -193,6 +193,8 @@ registry:
keywords: '' keywords: ''
description: '' description: ''
analytics: '' analytics: ''
matomo-analytics-url: ''
matomo-analytics-id: ''
allow-indexation: true allow-indexation: true
home-presentation-mode: COOLIRIS home-presentation-mode: COOLIRIS
modules: modules: