Skip to content

Commit 4b156a3

Browse files
Optimize Google Analytics placement and further relax CSP for compatibility
1 parent ade270e commit 4b156a3

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

_configs/_config_production.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ url: https://www.syclops.org
22

33
# Fathom Analytics Token
44
fa: 'QLYBRUST'
5+
6+
# Google Analytics Token
7+
ga: 'G-BKNJ7GJM13'

_layouts/page.html

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@
1010
<html lang="en">
1111

1212
<head>
13+
{% if site.ga and site.ga != "" %}
14+
<!-- Google tag (gtag.js) -->
15+
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.ga }}"></script>
16+
<script>
17+
window.dataLayer = window.dataLayer || [];
18+
function gtag() { dataLayer.push(arguments); }
19+
gtag('js', new Date());
20+
21+
gtag('config', '{{ site.ga }}');
22+
</script>
23+
{% endif %}
1324
<title>{{site.title}}</title>
1425

1526
<!-- Meta -->
@@ -52,36 +63,29 @@
5263
script-src
5364
'self'
5465
'unsafe-inline'
66+
'unsafe-eval'
5567
https://code.jquery.com
5668
https://www.googletagmanager.com
69+
https://www.google-analytics.com
5770
https://cdn.usefathom.com/script.js;
5871
connect-src
5972
'self'
6073
https://*.google-analytics.com
6174
https://*.analytics.google.com
75+
https://*.googletagmanager.com
6276
https://cdn.usefathom.com;
6377
img-src
6478
'self'
6579
https:
6680
http:
6781
data:
6882
https://www.google-analytics.com
83+
https://www.googletagmanager.com
6984
https://cdn.usefathom.com;
7085
frame-src
7186
'self'
7287
https://www.youtube.com;" http-equiv="Content-Security-Policy" />
7388

74-
{% if site.ga and site.ga != "" %}
75-
<!-- Google tag (gtag.js) -->
76-
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.ga }}"></script>
77-
<script>
78-
window.dataLayer = window.dataLayer || [];
79-
function gtag() { dataLayer.push(arguments); }
80-
gtag('js', new Date());
81-
82-
gtag('config', '{{ site.ga }}');
83-
</script>
84-
{% endif %}
8589
</head>
8690

8791
<body>

0 commit comments

Comments
 (0)