Zenn記事のサンプルコード
CRA を TypeScript で行い、react-router-dom をインストール。 その後、トラッキングの設定を行っている。 最低限トップページとアバウトページを用意した。
git clone git@github.com:mamezou/send-ga-react.git
cd send-ga-react
yarn
yarn start
最低限以下ファイルの UA と G から始まる箇所を変更すれば使える。 なお、env ファイルで管理する方法もあるが省略。 public/index.html src/router/router.tsx