Skip to content

Commit b5ba96d

Browse files
Merge pull request #178 from Web-Dev-Path/feature/ga-4-integration
Integrate Google Analytics 4
2 parents 7953bca + 45aeba1 commit b5ba96d

File tree

8 files changed

+1776
-1368
lines changed

8 files changed

+1776
-1368
lines changed

.env-template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ NEXT_PUBLIC_MAILCHIMP_URL={Add the url link}
77
NEXT_PUBLIC_RECAPTCHA_SITE_KEY={Add the key}
88
RECAPTCHA_SECRET_KEY={Add the key}
99
SENDGRID_API_KEY={Add the key}
10+
NEXT_PUBLIC_GA_MEASUREMENT_ID={Add the key}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ node_modules
44
.env
55
.DS_Store
66
yarn-error.log
7+
.yarn/*
8+
!.yarn/releases
9+
!.yarn/plugins
10+
!.yarn/sdks
711

812
# PWA files
913
**/public/sw.js

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,4 +108,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
108108
-
109109

110110
### Fixed
111-
- Remove `babel-plugin-styled-components` to use nextjs built in compiler
111+
- Remove `babel-plugin-styled-components` to use nextjs built in compiler
112+
113+
### Added
114+
115+
- Added Google Analytics 4 Integration

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This is how to get started locally:
2828

2929
- [Git clone this repository](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository-from-github/cloning-a-repository)
3030
- Ask on Slack for the `.env` file credentials with MailChimp and reCaptcha keys and add it to your local copy.
31+
- Keep the `.env-template` file and create a `.env` file with the credentials
3132
- Run `yarn install`
3233
- Run `yarn run dev` (for Windows)
3334
- Run `yarn run dev-mac` (for macOS)

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@sendgrid/mail": "^7.7.0",
2323
"html-entities": "^2.3.2",
2424
"next": "^13.1.6",
25+
"next-ga": "^2.3.4",
2526
"next-pwa": "^5.6.0",
2627
"react": "^18.2.0",
2728
"react-dom": "^18.2.0",
@@ -36,7 +37,8 @@
3637
"husky": "^8.0.0",
3738
"lint-staged": "^13.0.3",
3839
"prettier": "^2.7.1",
39-
"prettylint": "^1.0.0"
40+
"prettylint": "^1.0.0",
41+
"webpack": "^5.88.1"
4042
},
4143
"resolutions": {
4244
"styled-components": "^5"

pages/_app.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import Layout from '@/components/layout/Layout';
22
import '@/styles/globals.scss';
3+
import withGA from 'next-ga';
4+
import Router from 'next/router';
5+
6+
const GA_KEY = process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID;
37

48
function MyApp({ Component, pageProps }) {
59
return (
@@ -21,4 +25,4 @@ function MyApp({ Component, pageProps }) {
2125
// return { ...appProps }
2226
// }
2327

24-
export default MyApp;
28+
export default withGA(GA_KEY, Router)(MyApp);

yarn.lock

Lines changed: 1756 additions & 1365 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)