Skip to content

Commit e2b6073

Browse files
Merge pull request #482 from CodeForPhilly/fixes/preprod-ingress-gtm-injection
Fixes/preprod ingress gtm injection
2 parents 1eef8e2 + e4c934f commit e2b6073

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

k8s.preprod/app-ingress.yaml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,13 @@ metadata:
1313
# allow requests larger than 1MiB
1414
nginx.ingress.kubernetes.io/proxy-body-size: "0"
1515
nginx.ingress.kubernetes.io/configuration-snippet: |
16-
location / {
17-
sub_filter </head>
18-
'<!-- Google Tag Manager -->
19-
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
20-
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
21-
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
22-
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
23-
})(window,document,'script','dataLayer','GTM-KBZ6ZKX');</script>
24-
<!-- End Google Tag Manager -->';
25-
sub_filter </body>
26-
'<!-- Google Tag Manager (noscript) -->
27-
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KBZ6ZKX"
28-
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
29-
<!-- End Google Tag Manager (noscript) -->'
30-
sub_filter_once on;
31-
}
16+
# Inject Google Tag Manager:
17+
18+
proxy_set_header Accept-Encoding ""; # upstream compression must be disabled
19+
20+
sub_filter '</head>' '<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({"gtm.start": new Date().getTime(),event:"gtm.js"});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!="dataLayer"?"&l="+l:"";j.async=true;j.src="https://www.googletagmanager.com/gtm.js?id="+i+dl;f.parentNode.insertBefore(j,f); })(window,document,"script","dataLayer","GTM-KBZ6ZKX");</script></head>';
21+
22+
sub_filter '</body>' '<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KBZ6ZKX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript></body>';
3223
spec:
3324
tls:
3425
- hosts:
@@ -62,7 +53,6 @@ metadata:
6253
proxy_cache_bypass $http_x_purge;
6354
proxy_cache_key $proxy_upstream_name$request_uri;
6455
proxy_cache_lock on;
65-
proxy_cache_use_stale updating;
6656
add_header X-Cache-Status $upstream_cache_status;
6757
spec:
6858
rules:

k8s.prod/app-ingress.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ metadata:
7171
proxy_cache_bypass $http_x_purge;
7272
proxy_cache_key $proxy_upstream_name$request_uri;
7373
proxy_cache_lock on;
74-
proxy_cache_use_stale updating;
7574
add_header X-Cache-Status $upstream_cache_status;
7675
spec:
7776
rules:

0 commit comments

Comments
 (0)