Add Matomo tracking

This commit is contained in:
Sebastien Hattry 2023-04-21 12:19:58 +00:00
parent 378f072b2e
commit 4fb3745054
4 changed files with 31 additions and 30 deletions

View file

@ -33,8 +33,8 @@ MAIL_FROM_NAME="${APP_NAME}"
# Exception Handler
MAIL_LIST_SERVICEWEB=
# Google Analytics
GOOGLE_ANALYTICS_ID=
# Matomo
MATOMO_SITE_ID=
# Google Recaptcha
GOOGLE_RECAPTCHA_PUBLIC=
GOOGLE_RECAPTCHA_PRIVATE=

View file

@ -44,11 +44,11 @@ class SecureHeaders
$response->headers->set('X-Frame-Options', 'SAMEORIGIN');
$response->headers->set('Strict-Transport-Security', 'max-age=31536000; includeSubDomains;');
$cspPolicies = [
"default-src 'self' https://www.youtube.com https://www.google-analytics.com;",
"default-src 'self' https://www.youtube.com;",
"manifest-src 'self';",
// * CKEDITOR Specific https://ckeditor.com/docs/ckeditor5/latest/installation/advanced/csp.html
"connect-src 'self' https://www.youtube.com https://www.google-analytics.com;",
"img-src *;",
"connect-src 'self' https://www.youtube.com https://yl.s-web.fr blob:;",
"img-src * https://yl.s-web.fr data: blob:;",
// "frame-src https://www.youtube.com;",
"font-src 'self';",
// ! Using CKEditor will must have unsafe-inline style
@ -57,7 +57,11 @@ class SecureHeaders
// ! If you dont use ckeditor use this
// "style-src 'self' $cssDev;",
// phpcs:ignore Generic.Files.LineLength.TooLong
"script-src 'self' https://www.googletagmanager.com https://www.google-analytics.com $jsDev;"
'script-src ' . implode(" ", [
'\'self\'',
'https://yl.s-web.fr'
]) . ' ' . $jsDev . ';'
];
$response->headers->set(
'Content-Security-Policy',

View file

@ -22,6 +22,9 @@ return [
'public' => env('GOOGLE_RECAPTCHA_PUBLIC'),
'private' => env('GOOGLE_RECAPTCHA_PRIVATE'),
'version' => env('GOOGLE_RECAPTCHA_VERSION', "3") === "3" ? true : false
]
],
],
'matomo' => [
'site_id' => env('MATOMO_SITE_ID')
],
];

View file

@ -112,29 +112,23 @@
<script nonce="{{ $nonce }}">
document.addEventListener('DOMContentLoaded', () => {
window.LdcwebCn = new LdcwebCn({
'analytics': {
'name': "MESURES D'AUDIENCE - Google Analytics",
'description': 'Les services de mesure d\'audience permettent de générer des statistiques de fréquentation utiles à l\'amélioration du site.',
'link': 'https://support.google.com/analytics/answer/6004245',
'labelLink': 'En savoir plus',
'cookies': ['NID', '_ga', '_gat_gtag_UA_100712004_1', '_gid'],
'script': function() {
(function(d, t) {
var g = d.createElement(t),
s = d.getElementsByTagName(t)[0];
g.src = 'https://www.googletagmanager.com/gtag/js?id=UA-100712004-1';
g.id = 'analytics';
s.parentNode.insertBefore(g, s)
}(document, 'script'));
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-100712004-1');
'matomo': {
'name': "Matomo",
'description': 'Service d\'analyse d\'audience',
'link': 'https://fr.matomo.org/gdpr-analytics/',
'cookies': ['_pk'],
'script': function () {
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//yl.s-web.fr/";
_paq.push(['setTrackerUrl', u+'rainbow']);
_paq.push(['setSiteId', '{{ config("services.matomo.site_id") }}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'unicorn'; s.parentNode.insertBefore(g,s);
})();
}
},
'youtube': {