Merge branch 'feat/seo-ctr-copy' — 지역 페이지 절반에 검색 결과 새 문구, 클릭률 비교
# Conflicts: # docs/이벤트_추적.md # frontend/src/lib/analytics.ts
This commit is contained in:
commit
afa83d8b79
7 files changed
+463
-14
No files matched your search
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user