Skip to content

Commit

Permalink
[Third parties] Google analytics Add debug mode (#63405)
Browse files Browse the repository at this point in the history
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
  • Loading branch information
erwannbst and huozhi committed Sep 17, 2024
1 parent ef06571 commit 05dd22d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 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', nonce } = props
const { gaId, debugMode, dataLayerName = 'dataLayer', nonce } = props

if (currDataLayerName === undefined) {
currDataLayerName = dataLayerName
Expand Down Expand Up @@ -43,7 +43,7 @@ export function GoogleAnalytics(props: GAParams) {
function gtag(){window['${dataLayerName}'].push(arguments);}
gtag('js', new Date());
gtag('config', '${gaId}');`,
gtag('config', '${gaId}' ${debugMode ? ",{ 'debug_mode': true }" : ''});`,
}}
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 @@ -24,6 +24,7 @@ export type GTMParams = {
export type GAParams = {
gaId: string
dataLayerName?: string
debugMode?: boolean
nonce?: string
}

Expand Down

0 comments on commit 05dd22d

Please sign in to comment.