Skip to content

Commit 920b589

Browse files
authored
Merge pull request Expensify#63605 from Expensify/arosiclair-nonce
[No QA] Improve GTM script injection
2 parents 5ee16b6 + 3d8f66b commit 920b589

3 files changed

Lines changed: 8 additions & 16 deletions

File tree

config/webpack/webpack.common.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ const getCommonConfiguration = ({file = '.env', platform = 'web'}: Environment):
117117
{from: 'web/robots.txt'},
118118
{from: 'assets/images/expensify-app-icon.svg'},
119119
{from: 'web/manifest.json'},
120-
{from: 'web/thirdPartyScripts.js'},
121120
{from: 'assets/css', to: 'css'},
122121
{from: 'assets/fonts/web', to: 'fonts'},
123122
{from: 'assets/sounds', to: 'sounds'},

web/index.html

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,14 @@
130130
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
131131
<link rel="shortcut icon" id="favicon" href="/favicon.png">
132132
<% if (htmlWebpackPlugin.options.useThirdPartyScripts) { %>
133-
<!-- Third party scripts -->
134-
<script type="text/javascript" async="" src="/thirdPartyScripts.js" nonce="nonce-random-value"></script>
135-
<!-- End Third party scripts -->
133+
<!-- Google Tag Manager -->
134+
<script nonce='nonce-random-value'>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
135+
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
136+
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
137+
'https://www.googletagmanager.com/gtm.js?id='+i+dl;var n=d.querySelector('[nonce]');
138+
n&&j.setAttribute('nonce',n.nonce||n.getAttribute('nonce'));f.parentNode.insertBefore(j,f);
139+
})(window,document,'script','dataLayer','GTM-N4M3FLJZ');</script>
140+
<!-- End Google Tag Manager -->
136141
<% } %>
137142
<link rel="manifest" href="/manifest.json" />
138143
</head>

web/thirdPartyScripts.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)