Skip to content

Commit

Permalink
add google tag manager
Browse files Browse the repository at this point in the history
I installed "@next/third-parties" according to [next js docs](https://nextjs.org/docs/pages/building-your-application/optimizing/third-party-libraries#google-tag-manager). the [package docs](https://github.com/vercel/next.js/blob/a7a403f4982c4ce8dc3988bf96de4238362a704f/packages/third-parties/src/google/gtm.tsx)
show that it returns the necessary script tags. I was also able to see
the tag in local dev, before I hid the gtmId behind an environment
based conditional. (so that we only track on production)

ref: scientist-softserv/phenovista-digital-storefront#36
  • Loading branch information
alishaevn committed Jan 23, 2024
1 parent c26bcf8 commit 23c7a43
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 89 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ NEXT_PUBLIC_PROVIDER_ID=5159
NEXT_PUBLIC_SCIENTIST_API_VERSION=v2
NEXT_PUBLIC_WEBHOOK_URL=http://ss-mailer/webstore
NEXT_PUBLIC_APP_BASE_URL=https://webstore-staging.vercel.app

# optional/conditional variables
GOOGLE_TAG_MANAGER_ID=GTM-PQGCP24G
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"start": "next build && next start"
},
"dependencies": {
"@next/third-parties": "^14.1.0",
"@rjsf/core": "^5.0.0-beta.17",
"@rjsf/utils": "^5.0.0-beta.17",
"@rjsf/validator-ajv8": "^5.0.1",
Expand Down
3 changes: 3 additions & 0 deletions pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CookiePreferencesModal, Footer, Header } from '@scientist-softserv/webstore-component-library'
import { SWRConfig } from 'swr'
import { useRouter } from 'next/router'
import { GoogleTagManager } from '@next/third-parties/google'
import {
SessionProvider,
signIn,
Expand All @@ -20,6 +21,7 @@ import {
headerAndFooterLinkColors,
} from '../utils'
import '../utils/theme/globals.scss'
const gtmId = process.env.NODE_ENV === 'production' ? process.env.GOOGLE_TAG_MANAGER_ID : ''

const WebStore = ({ Component }) => {
/**
Expand All @@ -40,6 +42,7 @@ const WebStore = ({ Component }) => {
enableCookies={enableCookies}
getCookieConsent={getCookieConsent()}
/> */}
<GoogleTagManager gtmId={gtmId} />
<Header
auth={{
signIn: () => signIn(process.env.NEXT_PUBLIC_PROVIDER_NAME),
Expand Down
101 changes: 12 additions & 89 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,13 @@
resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-12.3.1.tgz#27d71a95247a9eaee03d47adee7e3bd594514136"
integrity sha512-W1ijvzzg+kPEX6LAc+50EYYSEo0FVu7dmTE+t+DM4iOLqgGHoW9uYSz9wCVdkXOEEMP9xhXfGpcSxsfDucyPkA==

"@next/third-parties@^14.1.0":
version "14.1.0"
resolved "https://registry.yarnpkg.com/@next/third-parties/-/third-parties-14.1.0.tgz#d9604fff8880e05d3804d2cf7ab42eb5430aec69"
integrity sha512-f55SdvQ1WWxi4mb5QqtYQh5wRzbm1XaeP7s39DPn4ks3re+n9VlFccbMxBRHqkE62zAyIKmvkUB2cByT/gugGA==
dependencies:
third-party-capital "1.0.20"

"@nodelib/[email protected]":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
Expand Down Expand Up @@ -1925,17 +1932,6 @@ array-includes@^3.1.5, array-includes@^3.1.6:
get-intrinsic "^1.1.3"
is-string "^1.0.7"

array-includes@^3.1.7:
version "3.1.7"
resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.7.tgz#8cd2e01b26f7a3086cbc87271593fe921c62abda"
integrity sha512-dlcsNBIiWhPkHdOEEKnehA+RNUWDc4UqFtnIXU4uuYDPtA4LDkr7qip2p0VvFAEXNDr0yWZ9PJyIRiGjRLQzwQ==
dependencies:
call-bind "^1.0.2"
define-properties "^1.2.0"
es-abstract "^1.22.1"
get-intrinsic "^1.2.1"
is-string "^1.0.7"

array-union@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d"
Expand Down Expand Up @@ -1982,16 +1978,6 @@ array.prototype.flatmap@^1.3.1:
es-abstract "^1.20.4"
es-shim-unscopables "^1.0.0"

array.prototype.flatmap@^1.3.2:
version "1.3.2"
resolved "https://registry.yarnpkg.com/array.prototype.flatmap/-/array.prototype.flatmap-1.3.2.tgz#c9a7c6831db8e719d6ce639190146c24bbd3e527"
integrity sha512-Ewyx0c9PmpcsByhSW4r+9zDU7sGjFc86qf/kKtuSCRdhfbk0SNLLkaT5qvcHnRGgc5NP/ly/y+qkXkqONX54CQ==
dependencies:
call-bind "^1.0.2"
define-properties "^1.2.0"
es-abstract "^1.22.1"
es-shim-unscopables "^1.0.0"

array.prototype.map@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/array.prototype.map/-/array.prototype.map-1.0.5.tgz#6e43c2fee6c0fb5e4806da2dc92eb00970809e55"
Expand All @@ -2014,19 +2000,6 @@ array.prototype.tosorted@^1.1.1:
es-shim-unscopables "^1.0.0"
get-intrinsic "^1.1.3"

arraybuffer.prototype.slice@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.2.tgz#98bd561953e3e74bb34938e77647179dfe6e9f12"
integrity sha512-yMBKppFur/fbHu9/6USUe03bZ4knMYiwFBcyiaXB8Go0qNehwX6inYPzK9U0NeQvGxKthcmHcaR8P5MStSRBAw==
dependencies:
array-buffer-byte-length "^1.0.0"
call-bind "^1.0.2"
define-properties "^1.2.0"
es-abstract "^1.22.1"
get-intrinsic "^1.2.1"
is-array-buffer "^3.0.2"
is-shared-array-buffer "^1.0.2"

asn1@~0.2.3:
version "0.2.6"
resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.6.tgz#0d3a7bb6e64e02a90c0303b31f292868ea09a08d"
Expand Down Expand Up @@ -4052,16 +4025,6 @@ get-intrinsic@^1.2.0:
has "^1.0.3"
has-symbols "^1.0.3"

get-intrinsic@^1.2.1, get-intrinsic@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.2.tgz#281b7622971123e1ef4b3c90fd7539306da93f3b"
integrity sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==
dependencies:
function-bind "^1.1.2"
has-proto "^1.0.1"
has-symbols "^1.0.3"
hasown "^2.0.0"

get-package-type@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a"
Expand Down Expand Up @@ -4685,13 +4648,6 @@ is-core-module@^2.11.0, is-core-module@^2.9.0:
dependencies:
has "^1.0.3"

is-core-module@^2.13.0, is-core-module@^2.13.1:
version "2.13.1"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.1.tgz#ad0d7532c6fea9da1ebdc82742d74525c6273384"
integrity sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==
dependencies:
hasown "^2.0.0"

is-date-object@^1.0.1, is-date-object@^1.0.5:
version "1.0.5"
resolved "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.5.tgz"
Expand Down Expand Up @@ -5586,16 +5542,6 @@ jsprim@^2.0.2:
array-includes "^3.1.5"
object.assign "^4.1.3"

jsx-ast-utils@^3.3.5:
version "3.3.5"
resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.3.5.tgz#4766bd05a8e2a11af222becd19e15575e52a853a"
integrity sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==
dependencies:
array-includes "^3.1.6"
array.prototype.flat "^1.3.1"
object.assign "^4.1.4"
object.values "^1.1.6"

keyv@^4.5.2:
version "4.5.2"
resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.5.2.tgz#0e310ce73bf7851ec702f2eaf46ec4e3805cce56"
Expand Down Expand Up @@ -6341,25 +6287,6 @@ object.fromentries@^2.0.6:
define-properties "^1.1.4"
es-abstract "^1.20.4"

object.fromentries@^2.0.7:
version "2.0.7"
resolved "https://registry.yarnpkg.com/object.fromentries/-/object.fromentries-2.0.7.tgz#71e95f441e9a0ea6baf682ecaaf37fa2a8d7e616"
integrity sha512-UPbPHML6sL8PI/mOqPwsH4G6iyXcCGzLin8KvEPenOZN5lpCNBZZQ+V62vdjB1mQHrmqGQt5/OJzemUA+KJmEA==
dependencies:
call-bind "^1.0.2"
define-properties "^1.2.0"
es-abstract "^1.22.1"

object.groupby@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/object.groupby/-/object.groupby-1.0.1.tgz#d41d9f3c8d6c778d9cbac86b4ee9f5af103152ee"
integrity sha512-HqaQtqLnp/8Bn4GL16cj+CUYbnpe1bh0TtEaWvybszDG4tgxCJuRpV8VGuvNaI1fAnI4lUJzDG55MXcOH4JZcQ==
dependencies:
call-bind "^1.0.2"
define-properties "^1.2.0"
es-abstract "^1.22.1"
get-intrinsic "^1.2.1"

object.hasown@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/object.hasown/-/object.hasown-1.1.2.tgz#f919e21fad4eb38a57bc6345b3afd496515c3f92"
Expand All @@ -6377,15 +6304,6 @@ object.values@^1.1.6:
define-properties "^1.1.4"
es-abstract "^1.20.4"

object.values@^1.1.7:
version "1.1.7"
resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.7.tgz#617ed13272e7e1071b43973aa1655d9291b8442a"
integrity sha512-aU6xnDFYT3x17e/f0IiiwlGPTy2jzMySGfUB4fq6z7CV8l85CWHDk5ErhyhpfDHhrOMwGFhSQkhMGHaIotA6Ng==
dependencies:
call-bind "^1.0.2"
define-properties "^1.2.0"
es-abstract "^1.22.1"

oidc-token-hash@^5.0.1:
version "5.0.1"
resolved "https://registry.npmjs.org/oidc-token-hash/-/oidc-token-hash-5.0.1.tgz"
Expand Down Expand Up @@ -7849,6 +7767,11 @@ text-table@^0.2.0:
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==

[email protected]:
version "1.0.20"
resolved "https://registry.yarnpkg.com/third-party-capital/-/third-party-capital-1.0.20.tgz#e218a929a35bf4d2245da9addb8ab978d2f41685"
integrity sha512-oB7yIimd8SuGptespDAZnNkzIz+NWaJCu2RMsbs4Wmp9zSDUM8Nhi3s2OOcqYuv3mN4hitXc8DVx+LyUmbUDiA==

throttleit@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-1.0.0.tgz#9e785836daf46743145a5984b6268d828528ac6c"
Expand Down

0 comments on commit 23c7a43

Please sign in to comment.