feat: GA search_landing — 구글·네이버 검색으로 지역 페이지에 들어오면 검색 결과 문구(새·예전)별로 보냄

This commit is contained in:
minaChoi committed 2026-10-30 14:43:39 +09:00
1 parent ce1d222216
commit d7fffc80a4
3 files changed
+14

No files matched your search

+12
View File
@@ -2,6 +2,7 @@ import { createContext, use } from 'react'
import { useLocation } from 'react-router'
import type { RegionData } from '@nalssigak/shared/api/client/types.gen'
import regionPages from '../../seo/region.json'
import { track } from '../lib/analytics'
export type LocateStatus = 'idle' | 'locating' | 'denied' | 'error'
@@ -21,6 +22,17 @@ export function pageOf(pathname: string) {
/** 지역 페이지로 들어오면 서버가 채운 소개 글(#root 안)을 앱이 덮기 전에 잡아 둔다. 구글은 JS 실행 뒤 화면으로 색인한다 */
const landingAbout = pageOf(location.pathname) ? { path: location.pathname, html: document.querySelector('#root > main')?.innerHTML ?? '' } : null
// 구글·네이버 검색으로 지역 페이지에 들어옴: 검색 결과 문구(새·예전, 서버가 못 채웠으면 none)별 유입을 견준다
const searchEngine = document.referrer ? new URL(document.referrer).hostname.match(/(?:^|\.)(google|naver)\./)?.[1] : undefined
if (landingAbout && (searchEngine === 'google' || searchEngine === 'naver')) {
const copy = document.querySelector<HTMLMetaElement>('meta[name="seo-copy"]')?.content
track('search_landing', {
page: location.pathname.startsWith('/tomorrow/') ? 'tomorrow' : 'today',
engine: searchEngine,
copy: copy === 'new' || copy === 'old' ? copy : 'none',
})
}
/** 들어온 지역 페이지에 그대로 있을 때만 그 소개 글 */
export function useLandingAbout(): string | null {
const { pathname } = useLocation()
+1
View File
@@ -27,6 +27,7 @@ type Events = {
talk_post: { topic: number; with_image: boolean }
feed_item_view: { item_type: 'talk' | 'event'; position: number }
hero_day_switch: { day: 'today' | 'tomorrow' }
search_landing: { page: 'today' | 'tomorrow'; engine: 'google' | 'naver'; copy: 'new' | 'old' | 'none' }
shorts_open: { video_id: string }
shorts_view: { video_id: string; index: number }
shorts_sound: { on: boolean }