29 lines
653 B
TypeScript
29 lines
653 B
TypeScript
import Script from "next/script";
|
|
|
|
const GoogleAnalytics = ({ ga_id }: { ga_id: string }) => (
|
|
<>
|
|
<Script
|
|
async
|
|
defer
|
|
strategy="afterInteractive"
|
|
src={`https://www.googletagmanager.com/gtag/js?
|
|
id=${ga_id}`}
|
|
></Script>
|
|
<Script
|
|
id="google-analytics"
|
|
defer
|
|
strategy="afterInteractive"
|
|
dangerouslySetInnerHTML={{
|
|
__html: `
|
|
window.dataLayer = window.dataLayer || [];
|
|
function gtag(){dataLayer.push(arguments);}
|
|
gtag('js', new Date());
|
|
|
|
gtag('config', '${ga_id}');
|
|
`,
|
|
}}
|
|
></Script>
|
|
</>
|
|
);
|
|
export default GoogleAnalytics;
|