PHRAS-2997- #comment add matomo script

This commit is contained in:
Harrys Ravalomanana
2020-03-24 17:38:39 +04:00
parent 7508ed8f93
commit 7d2941146a
7 changed files with 46 additions and 0 deletions

View File

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

View File

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

View File

@@ -0,0 +1,18 @@
{% if app['conf'].get(['registry', 'general', 'matomo-url']) != '' %}
{% if app['conf'].get(['registry', 'general', 'matomo-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-url']) }}/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', {{ app['conf'].get(['registry', 'general', 'matomo-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 bodyJavascript %}{% endblock %}
{% include 'common/analytics.html.twig' %}
{% include 'common/matomo_analytics.html.twig' %}
</body>
</html>

View File

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

View File

@@ -0,0 +1,18 @@
{% if app['conf'].get(['registry', 'general', 'matomo-url']) != '' %}
{% if app['conf'].get(['registry', 'general', 'matomo-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-url']) }}/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', {{ app['conf'].get(['registry', 'general', 'matomo-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 %}
{% block analytics %}
{% include 'common/analytics.html.twig' %}
{% include 'common/matomo_analytics.html.twig' %}
{% endblock analytics %}
{% block scripts %}{% endblock scripts %}