From 8fe5802664ac60f1beecfd86db1dc35ce7c626ef Mon Sep 17 00:00:00 2001 From: Peter Hudec Date: Mon, 16 Sep 2024 15:55:07 +0100 Subject: [PATCH] Reorganize Google Tag Manager snipped and initialization so that Export Wins Review and the rest of Data Hub have their own gtag initialization. --- src/apps/__export-wins-review/view.njk | 3 +- .../google-tag-manager-no-script.njk | 8 ----- .../_includes/google-tag-manager-snippet.njk | 35 ------------------- .../google-tag-manager/consent-needed.njk | 18 ++++++++++ .../google-tag-manager/consent-not-needed.njk | 22 ++++++++++++ .../google-tag-manager/gtag-definition.njk | 4 +++ .../google-tag-manager/no-script.njk | 6 ++++ .../_includes/google-tag-manager/snippet.njk | 8 +++++ src/templates/_layouts/template.njk | 4 +-- src/templates/react.njk | 2 +- 10 files changed, 63 insertions(+), 47 deletions(-) delete mode 100644 src/templates/_includes/google-tag-manager-no-script.njk delete mode 100644 src/templates/_includes/google-tag-manager-snippet.njk create mode 100644 src/templates/_includes/google-tag-manager/consent-needed.njk create mode 100644 src/templates/_includes/google-tag-manager/consent-not-needed.njk create mode 100644 src/templates/_includes/google-tag-manager/gtag-definition.njk create mode 100644 src/templates/_includes/google-tag-manager/no-script.njk create mode 100644 src/templates/_includes/google-tag-manager/snippet.njk diff --git a/src/apps/__export-wins-review/view.njk b/src/apps/__export-wins-review/view.njk index 6940a9266fd..54e094502a7 100644 --- a/src/apps/__export-wins-review/view.njk +++ b/src/apps/__export-wins-review/view.njk @@ -5,9 +5,10 @@ DBT Export Wins - {% include "_includes/google-tag-manager-snippet.njk" %} + {% include "_includes/google-tag-manager/consent-needed.njk" %} + {% include "_includes/google-tag-manager/no-script.njk" %} {% include "_includes/csp-nonce.njk" %}
diff --git a/src/templates/_includes/google-tag-manager-no-script.njk b/src/templates/_includes/google-tag-manager-no-script.njk deleted file mode 100644 index e9939c65bd2..00000000000 --- a/src/templates/_includes/google-tag-manager-no-script.njk +++ /dev/null @@ -1,8 +0,0 @@ -{% if GOOGLE_TAG_MANAGER_KEY %} - -{% endif %} diff --git a/src/templates/_includes/google-tag-manager-snippet.njk b/src/templates/_includes/google-tag-manager-snippet.njk deleted file mode 100644 index 774e630411f..00000000000 --- a/src/templates/_includes/google-tag-manager-snippet.njk +++ /dev/null @@ -1,35 +0,0 @@ -{% if GOOGLE_TAG_MANAGER_KEY %} - - - - -{% endif %} diff --git a/src/templates/_includes/google-tag-manager/consent-needed.njk b/src/templates/_includes/google-tag-manager/consent-needed.njk new file mode 100644 index 00000000000..863d56096ce --- /dev/null +++ b/src/templates/_includes/google-tag-manager/consent-needed.njk @@ -0,0 +1,18 @@ +{# +This is a set-up of Google Tag Manager for external users +(currently anyone who accessess /exportwins/review/*), +for whom we need to manage consent to use Google Analytics cookies. +#} +{% if GOOGLE_TAG_MANAGER_KEY %} +{% include "_includes/google-tag-manager/gtag-definition.njk" %} + +{% include "_includes/google-tag-manager/snippet.njk" %} +{% endif %} diff --git a/src/templates/_includes/google-tag-manager/consent-not-needed.njk b/src/templates/_includes/google-tag-manager/consent-not-needed.njk new file mode 100644 index 00000000000..6c429c77a73 --- /dev/null +++ b/src/templates/_includes/google-tag-manager/consent-not-needed.njk @@ -0,0 +1,22 @@ +{# +This is a set-up of Google Tag Manager for internal users, +who are assumed that they have given consent for using +Google Analytics cookies. +#} +{% if GOOGLE_TAG_MANAGER_KEY %} +{% include "_includes/google-tag-manager/gtag-definition.njk" %} + +{% include "_includes/google-tag-manager/snippet.njk" %} +{% endif %} diff --git a/src/templates/_includes/google-tag-manager/gtag-definition.njk b/src/templates/_includes/google-tag-manager/gtag-definition.njk new file mode 100644 index 00000000000..dd3adc9cc4c --- /dev/null +++ b/src/templates/_includes/google-tag-manager/gtag-definition.njk @@ -0,0 +1,4 @@ + diff --git a/src/templates/_includes/google-tag-manager/no-script.njk b/src/templates/_includes/google-tag-manager/no-script.njk new file mode 100644 index 00000000000..3da69fddfbe --- /dev/null +++ b/src/templates/_includes/google-tag-manager/no-script.njk @@ -0,0 +1,6 @@ +{% if GOOGLE_TAG_MANAGER_KEY %} + + + +{% endif %} diff --git a/src/templates/_includes/google-tag-manager/snippet.njk b/src/templates/_includes/google-tag-manager/snippet.njk new file mode 100644 index 00000000000..d6feb0d6b88 --- /dev/null +++ b/src/templates/_includes/google-tag-manager/snippet.njk @@ -0,0 +1,8 @@ + + + + diff --git a/src/templates/_layouts/template.njk b/src/templates/_layouts/template.njk index 844e5ac1189..5d922d04d4f 100644 --- a/src/templates/_layouts/template.njk +++ b/src/templates/_layouts/template.njk @@ -68,7 +68,7 @@ - {% include "_includes/google-tag-manager-snippet.njk" %} + {% include "_includes/google-tag-manager/consent-not-needed.njk" %}