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

+1
View File
@@ -45,6 +45,7 @@ GA4 태그(`gtag.js`, 측정 ID `G-D378J4X373`)를 `index.html`에 심고, 화
| `talk_post` | 이야기 글 올리기 성공 | `topic`(주제 번호, 6~9 는 기념일: 할로윈·빼빼로데이·크리스마스·추석), `with_image` | `talk.tsx` 글쓰기 `submit` |
| `feed_item_view` | 오늘 피드에 섞인 사람 글·행사 포스트가 처음 반쯤 보임 (한 장에 한 번) | `item_type: 'talk' \| 'event'`, `position`(피드에서 그 종류의 몇 번째) | `TodayPage.tsx` `Seen` |
| `hero_day_switch` | 히어로 오늘/내일 스위치를 바꿈 | `day: 'today' \| 'tomorrow'` | `TodayPage.tsx` |
| `search_landing` | 구글·네이버 검색 결과에서 지역 오늘·내일 페이지(/today·/tomorrow)로 들어옴 (페이지 열 때 한 번). 검색 결과 제목·설명 새 문구와 예전 문구의 유입을 견주려고 | `page: 'today' \| 'tomorrow'`, `engine: 'google' \| 'naver'`, `copy: 'new' \| 'old' \| 'none'`(서버가 넣은 `seo-copy` 표시, 서버가 못 채운 정적 페이지면 none. 새 문구 페이지 목록은 `backend/services/seo_copy_test.json`) | `regionContext.ts` |
| `shorts_open` | 쇼츠 페이지(/shorts/영상ID)로 들어옴 (오늘 화면 쇼츠 줄·공유 링크) | `video_id` | `Shorts.tsx` `ShortsPage` |
| `shorts_view` | 쇼츠를 넘겨 다른 영상으로 감 | `video_id`, `index`(목록 순서) | `Shorts.tsx` `ShortsPage` |
| `shorts_sound` | 쇼츠 소리 켜기·끄기 | `on` | `Shorts.tsx` `toggleSound` |
+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 }