From 7f97f68b5bb2b4540d9c266395f6de483e66440f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matja=C5=BE=20Horvat?= Date: Tue, 9 Apr 2024 19:10:26 +0200 Subject: [PATCH] Upgrade tracker code for Google Analytics 4 (#3172) Also update corresponding CSP settings --- pontoon/base/templates/tracker.html | 19 ++++++++----------- pontoon/settings/base.py | 4 ++-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/pontoon/base/templates/tracker.html b/pontoon/base/templates/tracker.html index 4f1008828e..723b528531 100644 --- a/pontoon/base/templates/tracker.html +++ b/pontoon/base/templates/tracker.html @@ -1,14 +1,11 @@ {% if settings.GOOGLE_ANALYTICS_KEY %} - - + - + gtag('config', '{{ settings.GOOGLE_ANALYTICS_KEY }}'); + {% endif %} - diff --git a/pontoon/settings/base.py b/pontoon/settings/base.py index b494bda8c6..65ae42bd70 100644 --- a/pontoon/settings/base.py +++ b/pontoon/settings/base.py @@ -825,8 +825,8 @@ def _allowed_hosts(): "'unsafe-eval'", "'sha256-fDsgbzHC0sNuBdM4W91nXVccgFLwIDkl197QEca/Cl4='", # Rules related to Google Analytics - "'sha256-G5/M3dBlZdlvno5Cibw42fbeLr2PTEGd1M909Z7vPZE='", - "https://www.google-analytics.com/analytics.js", + "'sha256-MAn2iEyXLmB7sfv/20ImVRdQs8NCZ0A5SShdZsZdv20='", + "https://www.googletagmanager.com/gtag/js", ) CSP_STYLE_SRC = ( "'self'",