From 442a6e85f3fcd5102a0ea36a62627a1545e19ae9 Mon Sep 17 00:00:00 2001
From: Habib Deriv <88178645+habib-deriv@users.noreply.github.com>
Date: Mon, 27 Nov 2023 10:51:15 +0600
Subject: [PATCH] Fix gtm partytown integration (#6038)
* chore: fix gtm partytown integration
* chore: remove defer
Downloading the script asynchronously is enough
---
gatsby-config.js | 3 ---
gatsby-ssr.js | 33 +++++++++++++++++++++------------
2 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/gatsby-config.js b/gatsby-config.js
index 27319ae5805..66d97899414 100644
--- a/gatsby-config.js
+++ b/gatsby-config.js
@@ -48,9 +48,6 @@ module.exports = {
`https://assets.customer.io/assets/track.js`,
`https://static.deriv.com/scripts/cookie.js`,
`https://widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js`,
- `https://cdn.livechatinc.com/tracking.js`,
- `https://www.google-analytics.com/analytics.js`,
- `https://www.googletagmanager.com/gtm.js?id=${process.env.GATSBY_GOOGLE_TAG_MANAGER_TRACKING_ID}`,
],
plugins: [
// [TODO] Enable this when we have a proper setup to enable caching, Otherwise it will cause one of them stop working.
diff --git a/gatsby-ssr.js b/gatsby-ssr.js
index 3d824a61786..7048a3cbbb8 100644
--- a/gatsby-ssr.js
+++ b/gatsby-ssr.js
@@ -14,29 +14,38 @@ export const onRenderBody = ({ setHeadComponents }) => {
const gtmTrackingId = process.env.GATSBY_GOOGLE_TAG_MANAGER_TRACKING_ID || ''
setHeadComponents([
+ // Partytown setup
,
,
+
+ // GTM setup
gtmTrackingId && (
+ ),
+ gtmTrackingId && (
+