Skip to content

Commit

Permalink
Merge pull request #9 from sajal2692/develop
Browse files Browse the repository at this point in the history
add partytown for lazy loading js and google analytics tag
  • Loading branch information
sajal2692 committed Jan 28, 2024
2 parents f01ec76 + 6bebf7b commit d7b301a
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
6 changes: 6 additions & 0 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import remarkToc from "remark-toc";
import remarkCollapse from "remark-collapse";
import sitemap from "@astrojs/sitemap";
import { SITE } from "./src/config";
import partytown from "@astrojs/partytown";

// https://astro.build/config
export default defineConfig({
Expand All @@ -15,6 +16,11 @@ export default defineConfig({
}),
react(),
sitemap(),
partytown({
config: {
forward: ["dataLayer.push"],
},
}),
],
markdown: {
remarkPlugins: [
Expand Down
30 changes: 29 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
},
"dependencies": {
"@astrojs/check": "^0.4.1",
"@astrojs/partytown": "^2.0.4",
"@astrojs/rss": "^4.0.1",
"@resvg/resvg-js": "^2.6.0",
"astro": "^4.1.1",
Expand Down
10 changes: 10 additions & 0 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ const socialImageURL = new URL(
<!-- Uncomment below to include animations -->
<!-- <ViewTransitions /> -->

<!-- Google tag (gtag.js) -->
<script type="text/partytown" async src="https://www.googletagmanager.com/gtag/js?id=G-JCR2S41KRX"></script>
<script type="text/partytown">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-JCR2S41KRX');
</script>

<script is:inline src="/toggle-theme.js"></script>
</head>
<body>
Expand Down

0 comments on commit d7b301a

Please sign in to comment.