121117 added event triggers
This commit is contained in:
@@ -1,21 +1,37 @@
|
||||
import Script from "next/script";
|
||||
import React, { Fragment } from "react";
|
||||
import { GoogleTagManager } from "@next/third-parties/google";
|
||||
|
||||
export const Tracking = ({ googleTagManagerID, nonce }) => (
|
||||
<Fragment>
|
||||
<>
|
||||
<Script
|
||||
strategy="afterInteractive"
|
||||
src={`https://www.googletagmanager.com/gtag/js?id=${googleTagManagerID}`}
|
||||
/>
|
||||
<Script
|
||||
id="google-analytics"
|
||||
strategy="afterInteractive"
|
||||
nonce={nonce}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: `(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','${googleTagManagerID}');`,
|
||||
__html: `
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('consent', 'default', {
|
||||
'analytics_storage': 'denied'
|
||||
});
|
||||
|
||||
gtag('config', '${googleTagManagerID}', {
|
||||
page_path: window.location.pathname,
|
||||
});
|
||||
`,
|
||||
}}
|
||||
/>
|
||||
</Fragment>
|
||||
|
||||
{/* <GoogleAnalytics gaId={googleTagManagerID} /> */}
|
||||
|
||||
{/* <GoogleTagManager gtmId={googleTagManagerID} /> */}
|
||||
</>
|
||||
);
|
||||
|
||||
export const TrackingNoScript = ({ googleTagManagerID }) => (
|
||||
|
||||
Reference in New Issue
Block a user