Skip to content

Commit

Permalink
analytics: rework for v4
Browse files Browse the repository at this point in the history
  • Loading branch information
mimecuvalo committed Nov 3, 2023
1 parent 8b9ebbf commit a99cd30
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions components/content/ContentHead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,20 @@ function StructuredMetaData({
// contentOwner currently.
function GoogleAnalytics({ contentOwner }: { contentOwner: UserPublic }) {
return (
<script
async
dangerouslySetInnerHTML={{
__html: `
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '${contentOwner.googleAnalytics}']);
_gaq.push(['_trackPageview']);
<>
<script async src={`https://www.googletagmanager.com/gtag/js?id=${contentOwner.googleAnalytics}`} />
<script
async
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
`,
}}
/>
gtag('config', '${contentOwner.googleAnalytics}');
`,
}}
/>
</>
);
}

0 comments on commit a99cd30

Please sign in to comment.