From d7fffc80a483c80c160d4bb8a996fe6a81f3a0f4 Mon Sep 17 00:00:00 2001 From: Mina Choi Date: Fri, 30 Oct 2026 14:43:39 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20GA=20search=5Flanding=20=E2=80=94=20?= =?UTF-8?q?=EA=B5=AC=EA=B8=80=C2=B7=EB=84=A4=EC=9D=B4=EB=B2=84=20=EA=B2=80?= =?UTF-8?q?=EC=83=89=EC=9C=BC=EB=A1=9C=20=EC=A7=80=EC=97=AD=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=EC=97=90=20=EB=93=A4=EC=96=B4=EC=98=A4?= =?UTF-8?q?=EB=A9=B4=20=EA=B2=80=EC=83=89=20=EA=B2=B0=EA=B3=BC=20=EB=AC=B8?= =?UTF-8?q?=EA=B5=AC(=EC=83=88=C2=B7=EC=98=88=EC=A0=84)=EB=B3=84=EB=A1=9C?= =?UTF-8?q?=20=EB=B3=B4=EB=83=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/이벤트_추적.md | 1 + frontend/src/b/regionContext.ts | 12 ++++++++++++ frontend/src/lib/analytics.ts | 1 + 3 files changed, 14 insertions(+) diff --git a/docs/이벤트_추적.md b/docs/이벤트_추적.md index fbdf6d7..0b6734f 100644 --- a/docs/이벤트_추적.md +++ b/docs/이벤트_추적.md @@ -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` | diff --git a/frontend/src/b/regionContext.ts b/frontend/src/b/regionContext.ts index 5ee0226..d57e0a1 100644 --- a/frontend/src/b/regionContext.ts +++ b/frontend/src/b/regionContext.ts @@ -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('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() diff --git a/frontend/src/lib/analytics.ts b/frontend/src/lib/analytics.ts index 9fc42b5..02ebfc7 100644 --- a/frontend/src/lib/analytics.ts +++ b/frontend/src/lib/analytics.ts @@ -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 }