hof 20.3.6-beta-gtm → 20.3.6
Sign up to get free protection for your applications and to get access to all the features.
- package/config/hof-defaults.js +8 -1
- package/frontend/template-partials/views/partials/head.html +3 -6
- package/lib/ga-tag.js +6 -37
- package/package.json +1 -1
- package/.nyc_output/c84e394d-abf7-4aea-99aa-36427e671442.json +0 -1
- package/.nyc_output/processinfo/c84e394d-abf7-4aea-99aa-36427e671442.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
- package/frontend/govuk-template/govuk_template_generated.html +0 -103
- package/sandbox/apps/sandbox/translations/en/default.json +0 -220
- package/sandbox/public/css/app.css +0 -9387
- package/sandbox/public/images/icons/icon-caret-left.png +0 -0
- package/sandbox/public/images/icons/icon-complete.png +0 -0
- package/sandbox/public/images/icons/icon-cross-remove-sign.png +0 -0
- package/sandbox/public/js/bundle.js +0 -35664
package/config/hof-defaults.js
CHANGED
@@ -22,7 +22,14 @@ const defaults = {
|
|
22
22
|
env: process.env.NODE_ENV || 'development',
|
23
23
|
gaTagId: process.env.GA_TAG || 'Test-GA-Tag',
|
24
24
|
ga4TagId: process.env.GA_4_TAG,
|
25
|
-
|
25
|
+
// added to allow support for multiple HOF forms using GTM to customize how they track page views
|
26
|
+
gtm: {
|
27
|
+
tagId: process.env.GTM_TAG || false,
|
28
|
+
config: {},
|
29
|
+
composePageName: function (page, convertPage) {
|
30
|
+
return convertPage(page);
|
31
|
+
}
|
32
|
+
},
|
26
33
|
gaCrossDomainTrackingTagId: process.env.GDS_CROSS_DOMAIN_GA_TAG,
|
27
34
|
loglevel: process.env.LOG_LEVEL || 'info',
|
28
35
|
ignoreMiddlewareLogs: ['/healthz'],
|
@@ -3,12 +3,9 @@
|
|
3
3
|
<!-- Google Tag Manager Data Layer -->
|
4
4
|
<script {{#nonce}}nonce="{{nonce}}"{{/nonce}}>
|
5
5
|
var dataLayer = window.dataLayer || [];
|
6
|
-
dataLayer.push(
|
7
|
-
|
8
|
-
|
9
|
-
'applicationType': '{{applicationType}}',
|
10
|
-
'environmentType': '{{environmentType}}'
|
11
|
-
});
|
6
|
+
dataLayer.push(
|
7
|
+
{{{gtmConfig}}}
|
8
|
+
);
|
12
9
|
</script>
|
13
10
|
<!-- End Google Tag Manager Data Layer -->
|
14
11
|
|
package/lib/ga-tag.js
CHANGED
@@ -52,12 +52,11 @@ const setupPageMap = routes => {
|
|
52
52
|
module.exports = (app, config) => {
|
53
53
|
const gaTagId = config.gaTagId;
|
54
54
|
const ga4TagId = config.ga4TagId;
|
55
|
-
const
|
56
|
-
const environmentType = config.environmentType ? config.environmentType : 'dev';
|
55
|
+
const gtm = config.gtm;
|
57
56
|
const gaCrossDomainTrackingTagId = config.gaCrossDomainTrackingTagId;
|
58
57
|
const routes = config.routes;
|
59
58
|
|
60
|
-
if (gaTagId || ga4TagId ||
|
59
|
+
if (gaTagId || ga4TagId || gtm.tagId) {
|
61
60
|
const pageMap = setupPageMap(routes);
|
62
61
|
|
63
62
|
app.use((req, res, next) => {
|
@@ -74,47 +73,17 @@ module.exports = (app, config) => {
|
|
74
73
|
};
|
75
74
|
|
76
75
|
// Adding extra properties if a GTM TAG is available
|
77
|
-
if (
|
76
|
+
if (gtm.tagId) {
|
77
|
+
gtm.config.pageName = gtm.composePageName(page, convertToGTMPage);
|
78
78
|
Object.assign(properties, {
|
79
|
-
|
80
|
-
|
81
|
-
eventName: 'pageLoad',
|
82
|
-
pageName: `ETA | Customer Contact Webform | ${convertToGTMPage(page)}`,
|
83
|
-
applicationType: 'ETA | Customer Contact',
|
84
|
-
environmentType: environmentType
|
79
|
+
gtmConfig: JSON.stringify(gtm.config),
|
80
|
+
gtmTagId: gtm.tagId
|
85
81
|
});
|
86
82
|
}
|
87
|
-
|
88
83
|
res.locals = Object.assign(res.locals, properties);
|
89
84
|
next();
|
90
85
|
});
|
91
86
|
}
|
92
87
|
|
93
|
-
/*
|
94
|
-
if (gaTagId || ga4TagId || gtmTagId) {
|
95
|
-
const pageMap = setupPageMap(routes);
|
96
|
-
|
97
|
-
app.use((req, res, next) => {
|
98
|
-
const page = pageView(req.path, pageMap);
|
99
|
-
res.locals.gaAllowDebug = config.env === 'development';
|
100
|
-
|
101
|
-
if (gtmTagId) {
|
102
|
-
res.locals.gtmTagId = gtmTagId;
|
103
|
-
res.locals['gtm-page'] = convertToGTMPage(page);
|
104
|
-
res.locals.eventName = "pageLoad"
|
105
|
-
res.locals.pageName = `ETA | Customer Contact Webform | ${res.locals['gtm-page']}`
|
106
|
-
res.locals.applicationType = "ETA | Customer Contact"
|
107
|
-
res.locals.environmentType = environmentType;
|
108
|
-
}
|
109
|
-
res.locals.gaTagId = gaTagId;
|
110
|
-
res.locals.ga4TagId = ga4TagId;
|
111
|
-
res.locals.gaCrossDomainTrackingTagId = gaCrossDomainTrackingTagId;
|
112
|
-
res.locals['ga-id'] = gaTagId;
|
113
|
-
res.locals['ga-page'] = page;
|
114
|
-
next();
|
115
|
-
});
|
116
|
-
}
|
117
|
-
*/
|
118
|
-
|
119
88
|
return app;
|
120
89
|
};
|