Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit 98cc1ad

Browse files
authored
GTM event delay (#2505)
1 parent cb904dc commit 98cc1ad

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

gatsby-browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export const onRouteUpdate = () => {
177177
userId: client_information.user_id,
178178
}),
179179
})
180-
}, 50)
180+
}, 1500)
181181
}
182182

183183
export const wrapPageElement = WrapPagesWithLocaleContext

src/components/layout/layout.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ const Layout = ({
146146
(!is_eu_country || tracking_status === 'accepted') && !gtm_data && has_dataLayer
147147

148148
if (allow_tracking) {
149-
setGTMData({ event: 'allow_tracking' })
149+
window.onload = () => {
150+
window.setTimeout(() => {
151+
setGTMData({ event: 'allow_tracking' })
152+
}, 2000)
153+
}
150154
}
151155
setMounted(true)
152156
}

0 commit comments

Comments
 (0)