Skip to content

Commit 734a759

Browse files
committed
TD-4009: Google Tag Manager tracking for all Non Prod Environments [ Replaced hosting envirinment checking with the envirinment variable from the appsettings]
1 parent 879dda1 commit 734a759

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

LearningHub.Nhs.WebUI/Views/Shared/_GoogleTagManagerNoScriptPartial.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@inject LearningHub.Nhs.WebUI.Configuration.Settings settings
2-
@inject Microsoft.AspNetCore.Hosting.IWebHostEnvironment hostingEnv
3-
@if (settings.GoogleTagManagerEnabled && hostingEnv.EnvironmentName == "Production")
2+
@inject Microsoft.Extensions.Configuration.IConfiguration Configuration
3+
@if (settings.GoogleTagManagerEnabled && @Configuration["Environment"] == "Production")
44
{
55
<!-- Google Tag Manager (noscript) -->
66
<noscript><iframe src="https://www.googletagmanager.com/[email protected]"

LearningHub.Nhs.WebUI/Views/Shared/_GoogleTagManagerPartial.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
@inject LearningHub.Nhs.WebUI.Configuration.Settings settings
2-
@inject Microsoft.AspNetCore.Hosting.IWebHostEnvironment hostingEnv
2+
@inject Microsoft.Extensions.Configuration.IConfiguration Configuration
33
@{
44
var detectCookieStatusBeforePageLoad = (string)TempData["ObtainUserConsentToTrackPriorToPageLoad"]; // Need to capture cookie status before page load to avoid inconsistencies.
55
}
66

7-
@if (detectCookieStatusBeforePageLoad == "true" && settings.GoogleTagManagerEnabled && hostingEnv.EnvironmentName == "Production") // [BY] When the user consent for first time load the follolwing JS. To avoid inconsistencies a temp varaible has been set when the user consent cookie choice
7+
@if (detectCookieStatusBeforePageLoad == "true" && settings.GoogleTagManagerEnabled && @Configuration["Environment"] == "Production") // [BY] When the user consent for first time load the follolwing JS. To avoid inconsistencies a temp varaible has been set when the user consent cookie choice
88
{
99
<!-- Google Tag Manager -->
1010
<script>

0 commit comments

Comments
 (0)