Skip to content

Commit a891836

Browse files
Adding GTM (#2255)
* Google Analytics - adding GTM and GA * Adding GTM --------- Co-authored-by: Hugo Pernet <[email protected]>
1 parent 609defe commit a891836

File tree

7 files changed

+33
-3
lines changed

7 files changed

+33
-3
lines changed

.env.example

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@ CRM_TENANT_ID=#{{CRM_TENANT_ID}}
3939
CRM_APP_SECRET=#{{CRM_APP_SECRET}}
4040
CRM_SCOPE=#{{CRM_SCOPE}}
4141
CRM_VIEW_CURRENT=#{{CRM_VIEW_CURRENT}}
42-
CRM_VIEW_PAST=#{{CRM_VIEW_PAST}}
42+
CRM_VIEW_PAST=#{{CRM_VIEW_PAST}}
43+
44+
NEXT_PUBLIC_GTM_CONTAINER_ID=#{{ NEXT_PUBLIC_GTM_CONTAINER_ID }}

.github/workflows/build-and-deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
NEXT_PUBLIC_ALGOLIA_INDEX_NAME: ${{ secrets.NEXT_PUBLIC_ALGOLIA_INDEX_NAME }}
5555
NEXT_PUBLIC_ALGOLIA_API_KEY: ${{ secrets.NEXT_PUBLIC_ALGOLIA_API_KEY }}
5656
NEXT_PUBLIC_API_BASE_URL: ${{ vars.NEXT_PUBLIC_API_BASE_URL }}
57+
NEXT_PUBLIC_GTM_CONTAINER_ID: ${{ secrets.NEXT_PUBLIC_GTM_CONTAINER_ID }}
5758

5859
deploy:
5960
name: Deploy to Azure Web App

.github/workflows/build-artifacts.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ on:
4040
required: false
4141
NEXT_PUBLIC_API_BASE_URL:
4242
required: false
43+
NEXT_PUBLIC_GTM_CONTAINER_ID:
44+
required: false
4345
outputs:
4446
image_tag:
4547
description: 'Docker tag to deploy'
@@ -368,6 +370,7 @@ jobs:
368370
NEXT_PUBLIC_GISCUS_THEME_URL=${{ vars.NEXT_PUBLIC_GISCUS_THEME_URL }}
369371
NEXT_PUBLIC_API_BASE_URL=${{ secrets.NEXT_PUBLIC_API_BASE_URL }}
370372
NEXT_PUBLIC_BASE_PATH=${{ vars.NEXT_PUBLIC_BASE_PATH }}
373+
NEXT_PUBLIC_GTM_CONTAINER_ID=${{ secrets.NEXT_PUBLIC_GTM_CONTAINER_ID }}
371374
# CACHE COMPLETELY DISABLED
372375
no-cache: true
373376
# Clean up intermediate containers after build

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
ARG NEXT_PUBLIC_GISCUS_CATEGORY_ID
5555
ARG NEXT_PUBLIC_GISCUS_THEME_URL
5656
ARG NEXT_PUBLIC_BASE_PATH
57+
ARG NEXT_PUBLIC_GTM_CONTAINER_ID
5758

5859
# Build info environment variables (kept as before)
5960
ENV BUILD_TIMESTAMP=$BUILD_TIMESTAMP \
@@ -78,6 +79,7 @@
7879
NEXT_PUBLIC_GISCUS_CATEGORY_ID=$NEXT_PUBLIC_GISCUS_CATEGORY_ID \
7980
NEXT_PUBLIC_GISCUS_THEME_URL=$NEXT_PUBLIC_GISCUS_THEME_URL \
8081
NEXT_PUBLIC_BASE_PATH=$NEXT_PUBLIC_BASE_PATH \
82+
NEXT_PUBLIC_GTM_CONTAINER_ID=$NEXT_PUBLIC_GTM_CONTAINER_ID \
8183
NEXT_TELEMETRY_DISABLED=1
8284

8385
# Build the Next.js application

app/layout.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { GoogleTagManager } from "@next/third-parties/google";
12
import { Metadata } from "next";
23
import { Inter as FontSans, Lato, Nunito } from "next/font/google";
34
import React from "react";
45
import SiteLayout from "@/components/layout/layout";
56
import { cn } from "@/lib/utils";
6-
77
import "@/styles.css";
88
import UserClientProvider from "@/components/auth/UserClientProvider";
99
import { TailwindIndicator } from "@/components/ui/breakpoint-indicator";
@@ -45,6 +45,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
4545
<html lang="en" className={cn(fontSans.variable, nunito.variable, lato.variable)}>
4646
<body className="min-h-screen bg-background font-sans antialiased flex flex-col">
4747
<script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} />
48+
<GoogleTagManager gtmId={process.env.NEXT_PUBLIC_GTM_CONTAINER_ID!} />
4849
<UserClientProvider>
4950
<SiteLayout>{children}</SiteLayout>
5051
</UserClientProvider>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@giscus/react": "^3.1.0",
4141
"@headlessui/react": "^2.2.1",
4242
"@microsoft/applicationinsights-web": "^3.3.9",
43+
"@next/third-parties": "^15.5.6",
4344
"@radix-ui/react-avatar": "^1.1.3",
4445
"@radix-ui/react-slot": "^1.1.2",
4546
"@swc/helpers": "^0.5.17",

pnpm-lock.yaml

Lines changed: 21 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)