Skip to content

Commit 8ad6736

Browse files
authored
Merge pull request #2651 from TechnologyEnhancedLearning/Develop/Fix/TD-3880-Add-BodyJs-GoogleTagManager
TD-3880-GTM body JS added.
2 parents d092bee + 95bc8f3 commit 8ad6736

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

DigitalLearningSolutions.Web/Views/LearningPortal/SelfAssessments/_Layout.cshtml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66
@inject Microsoft.Extensions.Configuration.IConfiguration Configuration
77
@{
88
var userResearchUrl = Configuration["UserResearchUrl"];
9+
Context.Request.Cookies.TryGetValue("Dls-cookie-consent", out string cookieConsent);
910
}
1011
<!DOCTYPE html>
1112
<html lang="en">
1213
<head>
14+
@if (cookieConsent == "true")
15+
{
16+
@await Html.PartialAsync("~/Views/Shared/_GoogleTagManager.cshtml")
17+
}
1318
<meta charset="utf-8">
1419
<meta http-equiv="X-UA-Compatible" content="IE=edge">
1520
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
@@ -39,16 +44,13 @@
3944
<meta name="twitter:card" content="summary">
4045
<meta name="twitter:title" content="@(ViewData["twitter:title"] ?? ViewData["Title"] ?? "Digital Learning Solutions")">
4146
<meta name="twitter:description" content="@(ViewData["twitter:description"] ?? "")">
42-
@{
43-
Context.Request.Cookies.TryGetValue("Dls-cookie-consent", out string cookieConsent);
44-
}
45-
@if (cookieConsent == "true")
46-
{
47-
@await Html.PartialAsync("~/Views/Shared/_GoogleTagManager.cshtml")
48-
}
4947
</head>
5048

5149
<body>
50+
@if (cookieConsent == "true")
51+
{
52+
@await Html.PartialAsync("~/Views/Shared/_GoogleTagManagerBodyTagJs.cshtml")
53+
}
5254
<div id="pagewrapper">
5355
<script>document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');</script>
5456

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<noscript>
2+
<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KJPJHGW" height="0" width="0" style="display:none;visibility:hidden"></iframe>
3+
</noscript>

DigitalLearningSolutions.Web/Views/Shared/_Layout.cshtml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@
2222
var headerExtension = (string)ViewData[LayoutViewDataKeys.Application];
2323
var shouldDisplayHelpMenuItem = dlsSubApplication?.DisplayHelpMenuItem ?? headerExtension != DlsSubApplication.TrackingSystem.HeaderExtension;
2424
var userResearchUrl = Configuration["UserResearchUrl"];
25+
Context.Request.Cookies.TryGetValue("Dls-cookie-consent", out string cookieConsent);
2526
}
2627
<!DOCTYPE html>
2728
<html lang="en">
2829
<head>
29-
30+
@if (cookieConsent == "true")
31+
{
32+
@await Html.PartialAsync("~/Views/Shared/_GoogleTagManager.cshtml")
33+
}
3034
<meta charset="utf-8">
3135
<meta http-equiv="X-UA-Compatible" content="IE=edge">
3236
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
@@ -54,17 +58,13 @@
5458
<meta name="twitter:card" content="summary">
5559
<meta name="twitter:title" content="@(ViewData["twitter:title"] ?? ViewData[LayoutViewDataKeys.Title] ?? "Digital Learning Solutions")">
5660
<meta name="twitter:description" content="@(ViewData["twitter:description"] ?? "")">
57-
@{
58-
Context.Request.Cookies.TryGetValue("Dls-cookie-consent", out string cookieConsent);
59-
}
60-
@if (cookieConsent == "true")
61-
{
62-
@await Html.PartialAsync("~/Views/Shared/_GoogleTagManager.cshtml")
63-
}
6461
</head>
6562

6663
<body>
67-
64+
@if (cookieConsent == "true")
65+
{
66+
@await Html.PartialAsync("~/Views/Shared/_GoogleTagManagerBodyTagJs.cshtml")
67+
}
6868
<div id="pagewrapper">
6969
<header>
7070
<script>document.body.className = ((document.body.className) ? document.body.className + ' js-enabled' : 'js-enabled');</script>

0 commit comments

Comments
 (0)