๐Ÿงš Github Page Google Analytics - Gatsby ๋ธ”๋กœ๊ทธ์— GA์ถ”๊ฐ€

Github repository traffic

Github page๋กœ Gatsby blog๋ฅผ ๋ฐฐํฌํ•˜๊ณ 
๊นƒํ—™ repo์—์„œ traffic(clone, views, visitor)์„ ์ฃผ ๋‹จ์œ„๋กœ ๋ณผ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.
์ด ๋ธ”๋กœ๊ทธ์— ์ˆ˜์ง‘ํ•œ url ์™ธ์— ํฌ์ŠคํŒ…์„ ๊ณ„์† ์ถ”๊ฐ€ ํ•  ์˜ˆ์ •์ด๋ผ์„œ GA๋ฅผ ์ถ”๊ฐ€ํ•˜๋ ค ํ•ฉ๋‹ˆ๋‹ค.

2020 09 04 02 05 49


gatsby-plugin-google-analytics

๊นƒํ—™ ํŽ˜์ด์ง€๋กœ ๋ฐฐํฌํ•œ Gatsby blog์— GA(google analytics)๋ฅผ ์ถ”๊ฐ€ํ•˜๋ ค๋ฉด
gatsby์—์„œ ์ œ๊ณตํ•˜๋Š” gatsby-plugin-google-analytics ๋ฅผ installํ•ด์„œ plugin์— ์ถ”๊ฐ€ํ•ด์„œ ์„ค์ •ํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

์ด ๋ธ”๋กœ๊ทธ์—๋Š” gatsby-config.js ์™ธ์—
module.exports plugin์ด config.js์— Optional๋กœ ์ •๋ฆฌ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.


1. GoogleAnalytics

GA์— ๊ฐ€์ž…์„ ์ง„ํ–‰ํ•˜๋ฉด์„œ ์ถ”๊ฐ€ํ•œ ์‚ฌ์ดํŠธ์—
ํ•ด๋‹นํ•˜๋Š” ํŠธ๋ž˜ํ‚น id๋ฅผ Optional์— ์ž…๋ ฅํ•ด์„œ deployํ•˜๋ฉด

2. ํ™œ์„ฑํ™”

๋ฐ”๋กœ ํ™œ์„ฑํ™” ์ƒํƒœ๊ฐ€ ๋˜๋Š”๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

2020 09 04 01 30 02


3. ์ด ๋ธ”๋กœ๊ทธ์— GA๊ฐ€ ์„ค์น˜๋˜์–ด์žˆ๋Š” ๊ฒฝ๋กœ

package.json

@gatsby-plugin-google-analytics

gatsby-config.js

  {
    resolve: `gatsby-plugin-google-analytics`,
    options: {
      trackingId: googleAnalytics,
    },
  },

package-lock.json

  "gatsby-plugin-google-analytics": {
    "version": "2.1.31",
    "resolved": "https://registry.npmjs.org/gatsby-plugin-google-analytics/-/gatsby-plugin-google-analytics-2.1.31.tgz",
    "integrity": "sha512-vwx2eB703Yatp1ZQ0lQDiAG3k9gyvDEENRmtp+myfadI8Sgtq+LA+3OYGLeT0MYdifUTW0Lhcp3qoIrng/41zg==",
    "requires": {
      "@babel/runtime": "^7.7.6"
    }
  },

config.js

  googleAnalytics: 'GA ํŠธ๋ž˜ํ‚น ์•„์ด๋””'

GA๋Š” ์™œ ์ถ”๊ฐ€ํ•˜๊ฒŒ ๋˜์—ˆ์„๊นŒ

์ฒ˜์Œ์— ๋ธ”๋กœ๊ทธ๋ฅผ ๊ตฌ์ถ•ํ•˜๊ณ  ์•„๋ฌด๊ฒƒ๋„ ์—†๋Š” ์ƒํƒœ๋กœ ๋ฐฐํฌํ•  ๋•Œ
commit, push & deploy ํ•˜๋ฉด์„œ github traffic์— ํŠธ๋ž˜ํ”ฝ ๊ทธ๋ž˜ํ”„๋ฅผ ๋ณผ ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.

์ฒซ ๋ฐฐํฌ ํ•˜๊ณ  ๊ด€๋ฆฌํ•œ์ง€ 2์ฃผ ์ •๋„ ์ง€๋‚ฌ์„ ๋•Œ,
Git clones์— clone๊ณผ unique cloner ์ˆซ์ž๊ฐ€ ๋ช‡๋ฐฑ ์ด์ƒ์œผ๋กœ ์ƒ์Šนํ•˜๋Š” ๊ฒƒ์„ ๋ณด๊ณ 
์•„๋ฌด๊ฒƒ๋„ ์—†๋Š” repo๋ฅผ ์™œ ํด๋ก ํ•˜๋Š” ๊ฑธ๊นŒ ๋ผ๋Š” ์˜๋ฌธ์ด ์ƒ๊ฒจ์„œ ํ•œ๋‘ ๋‹ฌ ์ •๋„๋ฅผ ์‚ดํŽด๋ณด์•˜์Šต๋‹ˆ๋‹ค.

์ด ๋ธ”๋กœ๊ทธ๋ฅผ ๋‹ค๋ฅธ ๊ณณ์— ํ™๋ณดํ•œ ๊ฒƒ์ด ์•„๋‹ˆ๊ธฐ์—
ํ‰์†Œ์— ์•„๋ฌด๊ฒƒ๋„ ํ•˜์ง€ ์•Š์•˜์„ ๋•Œ์—๋Š” traffic์ด ์ฆ๊ฐ€ํ•˜์ง€ ์•Š๋Š”๋ฐ

commit์„ ์ž์ฃผ ํ•˜๋Š” ๋‚ ์ด๋‚˜ push์™€ deploy๋ฅผ ๋ช‡ ๋ฒˆ ํ•˜๋Š” ๋‚ ์—๋Š”
๋ฐฐํฌ ํšŸ์ˆ˜๊ฐ€ traffic์— ๋ฐ˜์˜์ด ๋˜๋Š” ๊ฒƒ ๊ฐ™์•˜์Šต๋‹ˆ๋‹ค.

๊ทธ๋ž˜ํ”„์— ๋ณด์—ฌ์ง€๋Š” ์ˆซ์ž์™€ ๋ฐฐํฌํ•œ ์ˆซ์ž๊ฐ€ ๋™์ผํ•˜์ง€๋Š” ์•Š๊ณ 
ํ•ญ์ƒ ๊ทธ๋ž˜ํ”„ ์ˆซ์ž๊ฐ€ ๋” ๋งŽ์•„์„œ ๋งค๋ฒˆ ์ •ํ™•ํ•˜๊ฒŒ ์ธก์ •ํ•˜์ง€๋Š” ๋ชปํ–ˆ์Šต๋‹ˆ๋‹ค.

์ •ํ™•ํ•˜์ง€ ์•Š์€ ํŠธ๋ž˜ํ”ฝ ๋•Œ๋ฌธ์— Google Analytics๋ฅผ ๋ถ™์ด๊ธฐ๋กœ ํ–ˆ์Šต๋‹ˆ๋‹ค.
clone ํšŸ์ˆ˜๋Š” GA์— ๋ฐ˜์˜๋˜์ง€ ์•Š๊ฒ ์ง€๋งŒ
tech ํฌ์ŠคํŒ…์„ ์กฐ๊ธˆ์”ฉ ์ž‘์„ฑํ•˜๊ธฐ๋กœ ํ•ด์„œ post๋ฅผ ๊ด€๋ฆฌํ•˜๋ ค GA๋ฅผ ์ถ”๊ฐ€ํ•˜์˜€์Šต๋‹ˆ๋‹ค.


ยฉ 2021 blog