Skip to content

Commit

Permalink
added nonce support for @next/third-parties GoogleAnalytics
Browse files Browse the repository at this point in the history
  • Loading branch information
naveen-bharathi committed May 7, 2024
1 parent 7348615 commit 1dfcf3e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
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
1 change: 1 addition & 0 deletions packages/third-parties/src/types/google.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type GTMParams = {
export type GAParams = {
gaId: string
dataLayerName?: string
nonce?: string
}

export type GoogleMapsEmbed = {
Expand Down

0 comments on commit 1dfcf3e

Please sign in to comment.