added tracking snippet with env variable
This commit is contained in:
@@ -19,3 +19,6 @@ I18N_DOMAIN = "cymru.local"
|
|||||||
//RELAYPATH = "test-pedw-hc"
|
//RELAYPATH = "test-pedw-hc"
|
||||||
//SASKEY = "kTLrs9UHwuW9Msc9uNfjf+89qLYT6ly80lK0zdTYJW4="
|
//SASKEY = "kTLrs9UHwuW9Msc9uNfjf+89qLYT6ly80lK0zdTYJW4="
|
||||||
//SASKEYNAME = "testpedwhcpolicy"
|
//SASKEYNAME = "testpedwhcpolicy"
|
||||||
|
|
||||||
|
|
||||||
|
GOOGLE_TAG_MANAGER = GTM-T78CBC3
|
||||||
@@ -40,12 +40,10 @@ const RenderTextfield = ({
|
|||||||
<div id="basicSearch-hint" className="govuk-hint ">
|
<div id="basicSearch-hint" className="govuk-hint ">
|
||||||
<span className="govuk-body-s">{hint1}</span>
|
<span className="govuk-body-s">{hint1}</span>
|
||||||
|
|
||||||
<p>
|
<ul className="govuk-body-s govuk-!-margin-top-3">
|
||||||
<ul className="govuk-body-s">
|
<li>{hint2} </li>
|
||||||
<li>{hint2} </li>
|
<li>{hint3}</li>
|
||||||
<li>{hint3}</li>
|
</ul>
|
||||||
</ul>
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<label className="govuk-label " htmlFor={id} id={id + "_label"}>
|
<label className="govuk-label " htmlFor={id} id={id + "_label"}>
|
||||||
{label}
|
{label}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
import React, { Fragment } from "react";
|
||||||
|
|
||||||
|
export const Tracking = ({ googleTagManagerID }) => (
|
||||||
|
<Fragment>
|
||||||
|
<script
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
||||||
|
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
||||||
|
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
||||||
|
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
|
||||||
|
})(window,document,'script','dataLayer','${googleTagManagerID}');`,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const TrackingNoScript = ({ googleTagManagerID }) => (
|
||||||
|
<Fragment>
|
||||||
|
<noscript>
|
||||||
|
<iframe
|
||||||
|
title="google analytics"
|
||||||
|
src={`https://www.googletagmanager.com/ns.html?id=${googleTagManagerID}`}
|
||||||
|
height="0"
|
||||||
|
width="0"
|
||||||
|
style={{ display: "none", visibility: "hidden" }}
|
||||||
|
/>
|
||||||
|
</noscript>
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
+7
-1
@@ -1,5 +1,6 @@
|
|||||||
import Document, { Html, Head, Main, NextScript } from "next/document";
|
import Document, { Html, Head, Main, NextScript } from "next/document";
|
||||||
import SkipLink from "../components/skiplink";
|
import SkipLink from "../components/skiplink";
|
||||||
|
import { Tracking, TrackingNoScript } from "../components/tracking";
|
||||||
//import basicAuthMiddleware from "nextjs-basic-auth-middleware";
|
//import basicAuthMiddleware from "nextjs-basic-auth-middleware";
|
||||||
|
|
||||||
class MyDocument extends Document {
|
class MyDocument extends Document {
|
||||||
@@ -19,10 +20,15 @@ class MyDocument extends Document {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const googleTagManagerID = process.env.GOOGLE_TAG_MANAGER || null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Html lang="en">
|
<Html lang="en">
|
||||||
<Head />
|
<Head>
|
||||||
|
<Tracking googleTagManagerID={googleTagManagerID} />
|
||||||
|
</Head>
|
||||||
<body className="js-enabled">
|
<body className="js-enabled">
|
||||||
|
<TrackingNoScript googleTagManagerID={googleTagManagerID} />
|
||||||
{!process.browser && (
|
{!process.browser && (
|
||||||
<script>
|
<script>
|
||||||
window.apiRoot = `{process.env.API_ROOT}`
|
window.apiRoot = `{process.env.API_ROOT}`
|
||||||
|
|||||||
Reference in New Issue
Block a user