skip to content
barorin&?

tailwind-nextjs-starter-blogでGoogle Analyticsを有効にする方法

/ 1 min read

Table of Contents

はじめに

このブログはtailwind-nextjs-starter-blogをベースに作成しています。
そこで、Google Analytics の設定を自分用にメモ。

方法

data/siteMetadata.js
analytics: {
...
googleAnalyticsId: 'ここを設定'
},
next.config.js
# script-srcとstyle-srcに設定追加
const ContentSecurityPolicy = `
...
script-src 'self' 'unsafe-eval' 'unsafe-inline' www.google-analytics.com ssl.google-analytics.com tagmanager.google.com www.googletagmanager.com giscus.app;
style-src 'self' 'unsafe-inline' tagmanager.google.com fonts.googleapis.com;
...
`