Skip to content

Commit

Permalink
chore: update google analytics script
Browse files Browse the repository at this point in the history
  • Loading branch information
timlrx committed Feb 7, 2023
1 parent cdb870a commit 1e82c4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-coats-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'pliny': patch
---

update google analytics to follow ga4 recommendations
8 changes: 3 additions & 5 deletions packages/pliny/src/analytics/GoogleAnalytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ export const GA = ({ googleAnalyticsId }: GoogleAnalyticsProps) => {
return (
<>
<Script
strategy="lazyOnload"
strategy="afterInteractive"
src={`https://www.googletagmanager.com/gtag/js?id=${googleAnalyticsId}`}
/>

<Script strategy="lazyOnload" id="ga-script">
<Script strategy="afterInteractive" id="ga-script">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${googleAnalyticsId}', {
page_path: window.location.pathname,
});
gtag('config', '${googleAnalyticsId}');
`}
</Script>
</>
Expand Down

0 comments on commit 1e82c4e

Please sign in to comment.