Skip to content

Commit

Permalink
VACMS-16501 gtm keys (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjheffner authored Jan 24, 2024
1 parent e301e7a commit f3d1a9f
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 7 deletions.
15 changes: 15 additions & 0 deletions READMEs/analytics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Analytics in next-build:

1. Google Tag Manager via [react-gtm-module](https://www.npmjs.com/package/react-gtm-module). See `src/pages/_app.tsx`

Existing content-build analytics tags for reference:

- [vagovdev](https://github.com/department-of-veterans-affairs/content-build/blob/main/src/site/assets/js/google-analytics/vagovdev.js)
- [vagovstaging](https://github.com/department-of-veterans-affairs/content-build/blob/main/src/site/assets/js/google-analytics/vagovstaging.js)
- [vagovprod](https://github.com/department-of-veterans-affairs/content-build/blob/main/src/site/assets/js/google-analytics/vagovprod.js)

2. VA.gov participates in the US government’s analytics program. See the data at analytics.usa.gov.

- https://github.com/digital-analytics-program/gov-wide-code

3. Datadog integration coming soon
2 changes: 1 addition & 1 deletion envs/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ REDIS_URL=redis://127.0.0.1:6379
# for local assets from vets-website
NEXT_PUBLIC_ASSETS_URL=/generated/

# google analytics (These are the dev environment credentials)
# Google Analytics (These are the dev environment credentials)
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID=GTM-WFJWBD
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_AUTH=N9BisSDKAwJENFQtQIEvXQ
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_PREVIEW=env-423
2 changes: 1 addition & 1 deletion envs/.env.gha
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DRUPAL_PREVIEW_SECRET=secret
DRUPAL_CLIENT_ID=Retrieve this from AWS SSM /cms/consumers/next-build/client_id
DRUPAL_CLIENT_SECRET=Retrieve this from AWS SSM /cms/consumers/next-build/client_secret

# google analytics (These are the dev environment credentials)
# Google Analytics (These are the dev environment credentials)
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID=GTM-WFJWBD
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_AUTH=N9BisSDKAwJENFQtQIEvXQ
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_PREVIEW=env-423
15 changes: 15 additions & 0 deletions envs/.env.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This is the standard lower environment for Content API.
NEXT_PUBLIC_DRUPAL_BASE_URL=https://prod.cms.va.gov/
NEXT_IMAGE_DOMAIN=https://prod.cms.va.gov/

NEXT_PUBLIC_ASSETS_URL=/generated/

# for Drupal preview
DRUPAL_PREVIEW_SECRET=secret
# store these securely in the build pipeline env
#DRUPAL_CLIENT_ID=Retrieve this from AWS SSM /cms/consumers/next-build/client_id
#DRUPAL_CLIENT_SECRET=Retrieve this from AWS SSM /cms/consumers/next-build/client_secret

# Google Analytics
# These print directly to the page so do not need to store in SSM.
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID=GTM-WFJWBD
17 changes: 17 additions & 0 deletions envs/.env.staging
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This is the standard lower environment for Content API.
NEXT_PUBLIC_DRUPAL_BASE_URL=https://staging.cms.va.gov/
NEXT_IMAGE_DOMAIN=https://staging.cms.va.gov/

NEXT_PUBLIC_ASSETS_URL=/generated/

# for Drupal preview
DRUPAL_PREVIEW_SECRET=secret
# store these securely in the build pipeline env
#DRUPAL_CLIENT_ID=Retrieve this from AWS SSM /cms/consumers/next-build/client_id
#DRUPAL_CLIENT_SECRET=Retrieve this from AWS SSM /cms/consumers/next-build/client_secret

# Google Analytics
# These print directly to the page so do not need to store in SSM.
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID=GTM-WFJWBD
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_AUTH=inC4EKQce9vlWpRVcowiyQ
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_PREVIEW=env-661
2 changes: 1 addition & 1 deletion envs/.env.tugboat
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ REDIS_URL=redis://redis:6379
# Where to source vets-website assets from
NEXT_PUBLIC_ASSETS_URL=/generated/

# google analytics
# Google Analytics (These are the dev environment credentials)
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID=GTM-WFJWBD
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_AUTH=N9BisSDKAwJENFQtQIEvXQ
NEXT_PUBLIC_GOOGLE_TAG_MANAGER_PREVIEW=env-423
Expand Down
2 changes: 1 addition & 1 deletion src/lib/analytics/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import TagManager from 'react-gtm-module'

export const GTM_ID = process.env.GOOGLE_TAG_MANAGER_ID
export const GTM_ID = process.env.NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID
export const TAG_MANAGER_ARGS = {
gtmId: process.env.NEXT_PUBLIC_GOOGLE_TAG_MANAGER_ID,
auth: process.env.NEXT_PUBLIC_GOOGLE_TAG_MANAGER_AUTH,
Expand Down
4 changes: 1 addition & 3 deletions src/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { GTM_ID } from '@/lib/analytics'
import Script from 'next/script'

const Document = () => {
const ASSETS_URL =
process.env.NEXT_PUBLIC_ASSETS_URL ||
'https://prod-va-gov-assets.s3-us-gov-west-1.amazonaws.com/generated/'
const ASSETS_URL = process.env.NEXT_PUBLIC_ASSETS_URL || '/generated/'

return (
<Html lang="en" dir="ltr">
Expand Down

0 comments on commit f3d1a9f

Please sign in to comment.