Skip to content

Commit

Permalink
fix(google-analytics): was not loading when extracted in separate com…
Browse files Browse the repository at this point in the history
…ponent
  • Loading branch information
hossam-magdy committed Dec 21, 2020
1 parent 4772ccd commit 4301436
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 29 deletions.
12 changes: 8 additions & 4 deletions 404.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import React from "https://esm.sh/react";

import { Head } from "https://deno.land/x/aleph/mod.ts";

import GoogleAnalyticsScript from "./components/google-analytics-script.tsx";
import { Head, Scripts } from "https://deno.land/x/aleph/mod.ts";

export default function App404() {
return (
<>
<Head>
<meta http-equiv="refresh" content="0;URL='/'" />
<GoogleAnalyticsScript />
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-6009068-7" />
<script>
{`window.dataLayer = window.dataLayer || [];`}
{`function gtag(){dataLayer.push(arguments);}`}
{`gtag('js', new Date());`}
{`gtag('config', 'UA-6009068-7');`}
</script>
</Head>
</>
);
Expand Down
12 changes: 8 additions & 4 deletions app.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { ComponentType } from "https://esm.sh/react";

import { Head } from "https://deno.land/x/aleph/mod.ts";

import GoogleAnalyticsScript from "./components/google-analytics-script.tsx";
import { Head, Scripts } from "https://deno.land/x/aleph/mod.ts";

export default function App(
{ Page, pageProps }: { Page: ComponentType<any>; pageProps: any },
Expand All @@ -12,7 +10,13 @@ export default function App(
<Head>
<title>Hossam Magdy</title>
<link rel="icon" href="/favicon.svg" />
<GoogleAnalyticsScript />
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-6009068-7" />
<script>
{`window.dataLayer = window.dataLayer || [];`}
{`function gtag(){dataLayer.push(arguments);}`}
{`gtag('js', new Date());`}
{`gtag('config', 'UA-6009068-7');`}
</script>
</Head>
<Page {...pageProps} />
</>
Expand Down
21 changes: 0 additions & 21 deletions components/google-analytics-script.tsx

This file was deleted.

0 comments on commit 4301436

Please sign in to comment.