forked from craigary/nobelium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scripts.js
35 lines (32 loc) · 1.05 KB
/
Scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import Script from 'next/script'
import { useConfig } from '@/lib/config'
const Scripts = () => {
const BLOG = useConfig()
return (
<>
{BLOG.analytics && BLOG.analytics.provider === 'ackee' && (
<Script
src={BLOG.analytics.ackeeConfig.tracker}
data-ackee-server={BLOG.analytics.ackeeConfig.dataAckeeServer}
data-ackee-domain-id={BLOG.analytics.ackeeConfig.domainId}
/>
)}
{BLOG.analytics && BLOG.analytics.provider === 'ga' && (
<>
<Script
src={`https://www.googletagmanager.com/gtag/js?id=${BLOG.analytics.gaConfig.measurementId}`}
/>
<Script strategy="lazyOnload" id="ga">
{`window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${BLOG.analytics.gaConfig.measurementId}', {
page_path: window.location.pathname,
});`}
</Script>
</>
)}
</>
)
}
export default Scripts