@@ -5,7 +5,6 @@ import "../src/styles/main.scss";
5
5
import Head from "next/head" ;
6
6
import { useForm , FormProvider } from "react-hook-form" ;
7
7
import isEmpty from "lodash/isEmpty" ;
8
- import gaUtils , { getGoogleGACode } from "../src/externals/gaUtils" ;
9
8
import {
10
9
FormDataContextProvider ,
11
10
formInitialState ,
@@ -28,24 +27,6 @@ interface MyAppProps {
28
27
pageProps : any ;
29
28
}
30
29
31
- /**
32
- * Determines if we are running on server or in the client.
33
- * @return {boolean } true if running on server
34
- */
35
- function isServerRendered ( ) : boolean {
36
- return typeof window === "undefined" ;
37
- }
38
-
39
- // Get the Google Analytics code for the HTML snippet below.
40
- const isProduction = appConfig . nodeEnv === "production" ;
41
- const gaCode = getGoogleGACode ( isProduction ) ;
42
- // Set up Google Analytics if it isn't already. There's an HTML snippet in the
43
- // DOM below that initializes GA. If it fails, this tries again. The HTML
44
- // snippet is better since it works without javascript.
45
- if ( ! isServerRendered ( ) ) {
46
- gaUtils . setupAnalytics ( isProduction ) ;
47
- }
48
-
49
30
function MyApp ( { Component, pageProps } : MyAppProps ) {
50
31
const router = useRouter ( ) ;
51
32
useRouterScroll ( { top : 640 } ) ;
@@ -67,7 +48,6 @@ function MyApp({ Component, pageProps }: MyAppProps) {
67
48
useEffect ( ( ) => {
68
49
const handleRouteChange = ( ) => {
69
50
aaUtils . pageViewEvent ( window . location ) ;
70
- gaUtils . trackPageview ( window . location . pathname ) ;
71
51
} ;
72
52
router . events . on ( "routeChangeComplete" , ( ) => handleRouteChange ( ) ) ;
73
53
return router . events . off ( "routeChangeComplete" , ( ) => handleRouteChange ( ) ) ;
@@ -174,14 +154,12 @@ function MyApp({ Component, pageProps }: MyAppProps) {
174
154
< script
175
155
dangerouslySetInnerHTML = { {
176
156
__html : `
177
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
178
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
179
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
180
- })(document,'script','https://www.google-analytics.com/analytics.js','ga');
181
-
182
- ga('create', '${ gaCode } ', 'auto');
183
- ga('send', 'pageview');
184
- ` ,
157
+ (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
158
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
159
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
160
+ 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
161
+ })(window,document,'script','dataLayer','GTM-RKWC');
162
+ ` ,
185
163
} }
186
164
/>
187
165
{ /* <!-- End Google Analytics --> */ }
0 commit comments