feat: GTM 태그와 이벤트 추적(각·글 보기, 공유, 로그인·가입, 지역 변경)
This commit is contained in:
1 parent
e8382f450b
commit
ce6efe979a
5 files changed
+102
-1
No files matched your search
@@ -0,0 +1,21 @@
|
||||
/** GTM으로 보내는 이벤트와 값. 목록과 GTM 설정은 docs/이벤트_추적.md */
|
||||
type Events = {
|
||||
view_gak: { index_id: number; gak_name: string; score: number; rank: number }
|
||||
select_content: { content_type: 'article'; item_id: number; category: string }
|
||||
share: { content_type: 'image'; item_id: string; method: 'share_sheet' | 'download'; ratio: string }
|
||||
login: { method: 'id' }
|
||||
sign_up: { method: 'id' }
|
||||
region_change: { region_name: string; method: 'list' | 'location' }
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
dataLayer?: Record<string, unknown>[]
|
||||
}
|
||||
}
|
||||
|
||||
export function track<E extends keyof Events>(event: E, params: Events[E]) {
|
||||
if (import.meta.env.DEV) return
|
||||
window.dataLayer ??= []
|
||||
window.dataLayer.push({ event, ...params })
|
||||
}
|
||||
Reference in new issue
Block a user