Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/publish-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ jobs:
env:
NEXT_PUBLIC_COOKIEBOT_CBID: ${{ secrets.NEXT_PUBLIC_COOKIEBOT_CBID }}
NEXT_PUBLIC_GA_MEASUREMENT_ID: ${{ secrets.NEXT_PUBLIC_GA_MEASUREMENT_ID }}
Comment thread
michaelstaib marked this conversation as resolved.
NEXT_PUBLIC_GTM_ID: ${{ secrets.NEXT_PUBLIC_GTM_ID }}

- name: Build WebSite Container
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7
Expand Down
35 changes: 29 additions & 6 deletions website/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from "react";
import type { Metadata } from "next";
import { Radio_Canada } from "next/font/google";
import Script from "next/script";
import { GoogleAnalytics } from "@next/third-parties/google";

import { Providers } from "@/lib/providers";
import { siteMetadata } from "@/lib/site-config";
Expand Down Expand Up @@ -36,7 +35,7 @@ export default function RootLayout({

return (
<html lang="en" className={radioCanada.variable}>
<body>
<head>
{process.env.NEXT_PUBLIC_COOKIEBOT_CBID && (
<>
<Script
Expand Down Expand Up @@ -65,11 +64,35 @@ export default function RootLayout({
/>
</>
)}
{process.env.NEXT_PUBLIC_GTM_ID && (
<Script
id="gtm-script"
strategy="beforeInteractive"
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
(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','${process.env.NEXT_PUBLIC_GTM_ID}');
`,
}}
/>
)}
</head>
<body>
{process.env.NEXT_PUBLIC_GTM_ID && (
<noscript>
<iframe
src={`https://www.googletagmanager.com/ns.html?id=${process.env.NEXT_PUBLIC_GTM_ID}`}
height="0"
width="0"
style={{ display: "none", visibility: "hidden" }}
/>
</noscript>
)}
Comment thread
michaelstaib marked this conversation as resolved.
Outdated
<Providers latestBlogPost={latestBlogPost}>{children}</Providers>
{process.env.NEXT_PUBLIC_COOKIEBOT_CBID &&
process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID && (
<GoogleAnalytics gaId={process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID} />
)}
</body>
</html>
);
Expand Down
Loading