Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…s-handbook into main
  • Loading branch information
Leehaeun0 committed Aug 21, 2021
2 parents 94b81db + 8fe9527 commit dc8a66d
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 34 deletions.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@
개발자를 위한 웹 사용자 데이터 분석 핸드북
https://everyanalytics.github.io/web-analytics-handbook/

## 개발 명령어
## 환경 설정

```console
1. `.env`파일 추가

```
REACT_APP_GA_TRACKING_ID=트래킹아이디를적으세요.
```


## Installation

```bash
# 의존성 설치
yarn install

Expand All @@ -16,5 +25,17 @@ yarn start
yarn build

# 배포
GIT_USER=<Your GitHub username> USE_SSH=true yarn deploy
GIT_USER=<Your GitHub Username>
USE_SSH=true
yarn deploy
```
## 구성

1. 📚 핸드북
2. 💡 react-anlytics-provider
3. 👾 블로그
4. 🙋🏻 용어사전

### ❗️[용어사전](https://everyanalytics.github.io/web-analytics-handbook/wiki) 네이밍 규칙
- `${한글이름} (${영어이름})` 으로 표기
- 복수인 경우 `,` 로 구분 `ex. 측정기준 (Dimension), 측정항목 (Metrics)`
5 changes: 5 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const lightCodeTheme = require("prism-react-renderer/themes/github");
const darkCodeTheme = require("prism-react-renderer/themes/dracula");

const PLUGINS_WEBPACK_CONFIGURE_PATH = './src/plugins/webpack-configure/index.ts';

const TITLE = "Web Analytics Handbook";

/** @type {import('@docusaurus/types').DocusaurusConfig} */
Expand Down Expand Up @@ -115,4 +117,7 @@ module.exports = {
},
],
],
plugins: [
PLUGINS_WEBPACK_CONFIGURE_PATH,
]
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@types/react": "^17.0.16",
"@types/react-helmet": "^6.1.2",
"@types/react-router-dom": "^5.1.8",
"dotenv-webpack": "^7.0.3",
"babel-plugin-module-resolver": "^4.1.0",
"typescript": "^4.3.5",
"@typescript-eslint/eslint-plugin": "^4.29.1",
Expand Down
22 changes: 22 additions & 0 deletions src/plugins/webpack-configure/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const Dotenv = require("dotenv-webpack");

const DOTENV_DEFAULT_OPTIONS = {
path: "./.env",
safe: true,
allowEmptyValues: false,
systemvars: false,
silent: false,
expand: false,
defaults: false,
};

module.exports = () => {
return {
name: 'evn-setting',
configureWebpack(config, isServer) {
return {
plugins: [new Dotenv(DOTENV_DEFAULT_OPTIONS)],
};
},
};
};
31 changes: 0 additions & 31 deletions src/theme/Root.js

This file was deleted.

49 changes: 49 additions & 0 deletions src/theme/Root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import * as React from "react";
import Head from "@docusaurus/Head";

const GA_TRACKING_ID = process.env.REACT_APP_GA_TRACKING_ID;

const createInitializeGA = (GA_TRACKING_ID) => {
if(GA_TRACKING_ID === undefined || GA_TRACKING_ID === "") {
return `console.warn("GA가 초기화 실패되었습니다. 'GA_TRACKING_ID'가 정의되지 않았습니다.");`;
}
return `
console.info("✅GA가 초기화 되었습니다.")
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "${GA_TRACKING_ID}");
`
}

const createGtagPath = (GA_TRACKING_ID) => {
if(GA_TRACKING_ID === undefined) {
console.warn(`[web-analytics-handbook] Warnning Can't create gtag path. Because "GA_TRACKING_ID" is not defined.`);
return "";
}
return `https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`;
}

const gtagPath = createGtagPath(GA_TRACKING_ID);
const initializeGA = createInitializeGA(GA_TRACKING_ID);

function Root({ children }) {
return (
<>
<div>
<Head>
<script
async
src={`${gtagPath}`}
/>
<script>{initializeGA}</script>
</Head>
{children}
</div>
</>
);
}

export default Root;
12 changes: 12 additions & 0 deletions wiki.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,17 @@
{
"name": "태그 (Tag)",
"description": "태그를 통해 외부 링크나 GA 이벤트 등을 추적할 수 있다."
},
{
"name": "유료 검색 (Paid search)",
"description": "검색광고를 통해 획득한 유입 (광고를 통한 유입도 집계에 포함)"
},
{
"name": "자연 검색 (Organic search)",
"description": "광고 외의 유입으로 사용자가 사이트로 직접 유입된 상황 ex) 검색을 통한 유입"
},
{
"name": "기여 (Attribution)",
"description": "전환까지 도달한 유입 경로와 광고, 모든 접속 이력 분석을 통해 각각 전환 달성 성과에 대한 기여도를 측정하는 프로세스."
}
]

0 comments on commit dc8a66d

Please sign in to comment.