Skip to content

Commit

Permalink
ga: rework
Browse files Browse the repository at this point in the history
  • Loading branch information
mimecuvalo committed Nov 4, 2023
1 parent 07c974e commit 44c264c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
14 changes: 6 additions & 8 deletions components/content/ContentHead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { buildUrl, contentUrl, profileUrl } from 'util/url-factory';

import Head from 'next/head';
import { useTheme } from 'components';
import Script from 'next/script';

export default function ContentHead(props: {
content?: Content;
Expand Down Expand Up @@ -121,21 +122,18 @@ export default function ContentHead(props: {
<link rel="replies" type="application/atom+xml" href={repliesUrl} {...repliesAttribs} />
) : null}
{contentOwner ? (
<script async src={`https://www.googletagmanager.com/gtag/js?id=${contentOwner.googleAnalytics}`} />
<Script async src={`https://www.googletagmanager.com/gtag/js?id=${contentOwner.googleAnalytics}`} />
) : null}
{contentOwner ? (
<script
async
dangerouslySetInnerHTML={{
__html: `
<Script id="google-analytics-script" async>
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${contentOwner.googleAnalytics}');
`,
}}
/>
`}
</Script>
) : null}
</Head>
);
Expand Down
1 change: 1 addition & 0 deletions components/content/ContentQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default gql`
theme
viewport
license
googleAnalytics
}
fetchSiteMap(username: $username) {
Expand Down
2 changes: 2 additions & 0 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const generateCsp = (nonce: string) => {
'https://cdn.auth0.com',
'https://cdn.vercel-insights.com',
'https://va.vercel-scripts.com',
'https://www.googletagmanager.com',
'https://www.google-analytics.com',
].concat(isDevelopment ? ["'unsafe-inline'", "'unsafe-eval'"] : [`'nonce-${nonce}'`]),

// XXX(mime): we have inline styles around - can we pass nonce around the app properly?
Expand Down

1 comment on commit 44c264c

@vercel
Copy link

@vercel vercel bot commented on 44c264c Nov 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.