Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nonce support next third parties #65453

Open
wants to merge 3 commits into
base: canary
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/third-parties/src/google/ga.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ declare global {
let currDataLayerName: string | undefined = undefined

export function GoogleAnalytics(props: GAParams) {
const { gaId, dataLayerName = 'dataLayer' } = props
const { gaId, dataLayerName = 'dataLayer', nonce = undefined } = props

if (currDataLayerName === undefined) {
currDataLayerName = dataLayerName
Expand Down Expand Up @@ -49,6 +49,7 @@ export function GoogleAnalytics(props: GAParams) {
<Script
id="_next-ga"
src={`https://www.googletagmanager.com/gtag/js?id=${gaId}`}
nonce={nonce}
/>
</>
)
Expand Down
3 changes: 2 additions & 1 deletion packages/third-parties/src/google/gtm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type { GTMParams } from '../types/google'
let currDataLayerName: string | undefined = undefined

export function GoogleTagManager(props: GTMParams) {
const { gtmId, dataLayerName = 'dataLayer', auth, preview, dataLayer } = props
const { gtmId, dataLayerName = 'dataLayer', auth, preview, dataLayer, nonce = undefined } = props

if (currDataLayerName === undefined) {
currDataLayerName = dataLayerName
Expand Down Expand Up @@ -48,6 +48,7 @@ export function GoogleTagManager(props: GTMParams) {
id="_next-gtm"
data-ntpc="GTM"
src={`https://www.googletagmanager.com/gtm.js?id=${gtmId}${gtmLayer}${gtmAuth}${gtmPreview}`}
nonce={nonce}
/>
</>
)
Expand Down
2 changes: 2 additions & 0 deletions packages/third-parties/src/types/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ export type GTMParams = {
dataLayerName?: string
auth?: string
preview?: string
nonce?: string
}

export type GAParams = {
gaId: string
dataLayerName?: string
nonce?: string
}

export type GoogleMapsEmbed = {
Expand Down