Skip to content

Commit

Permalink
feat: google analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Liendo committed Jun 10, 2022
1 parent 9e59ee5 commit 7c524bc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
NOTION_ACCESS_TOKEN=
NOTION_BLOG_DATABASE_ID_ES=
NOTION_BLOG_DATABASE_ID_EN=
NOTION_PROJECTS_DATABASE_ID=
NOTION_PROJECTS_DATABASE_ID=
GOOGLE_ANALYTICS=
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ jobs:
NOTION_BLOG_DATABASE_ID_ES: ${{ secrets.NOTION_BLOG_DATABASE_ID_ES }}
NOTION_BLOG_DATABASE_ID_EN: ${{ secrets.NOTION_BLOG_DATABASE_ID_EN }}
NOTION_PROJECTS_DATABASE_ID: ${{ secrets.NOTION_PROJECTS_DATABASE_ID }}
GOOGLE_ANALYTICS: ${{ secrets.GOOGLE_ANALYTICS }}
run: npm run build
19 changes: 18 additions & 1 deletion src/pages/_document.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,24 @@ export default function MyDocument() {
<meta name="author" content="Michael Liendo" />
<meta name="copyright" content="Michael Liendo" />

{/* Global Site Tag (gtag.js) - Google Analytics */}
<script
async
src={`https://www.googletagmanager.com/gtag/js?id=${process.env.GOOGLE_ANALYTICS}`}
/>
<script
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${process.env.GOOGLE_ANALYTICS}', {
page_path: window.location.pathname,
});
`,
}}
/>

<link href="/favicon.ico" rel="shortcut icon" />
<link
href="/images/seo-images/apple-icon-180x180.png"
Expand All @@ -53,7 +71,6 @@ export default function MyDocument() {
sizes="16x16"
type="image/png"
/>

<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
Expand Down

0 comments on commit 7c524bc

Please sign in to comment.