@@ -6,6 +6,7 @@ import Image from 'next/image';
66import KakaoMapRecommend from '@/components/map/kakaoMapRecommend' ;
77import { useRecommend } from '@/hooks/api/query/useRecommend' ;
88import { useCheckMeeting } from '@/hooks/api/query/useCheckMeeting' ;
9+ import { sendGAEvent } from '@next/third-parties/google' ;
910
1011function RecommendContent ( ) {
1112 const router = useRouter ( ) ;
@@ -139,15 +140,49 @@ function RecommendContent() {
139140 router . back ( ) ;
140141 } ;
141142
142- const handleOpenKakaoMap = ( e : React . MouseEvent , placeUrl ?: string ) => {
143+ const handleOpenKakaoMap = (
144+ e : React . MouseEvent ,
145+ placeUrl ?: string ,
146+ place ?: ( typeof places ) [ 0 ]
147+ ) => {
143148 e . stopPropagation ( ) ;
149+
150+ // 카카오맵에서 보기 클릭 시 GA 전송 (external_map_opened)
151+ if ( typeof window !== 'undefined' && meetingId && place ) {
152+ const browserId = localStorage . getItem ( 'browser_id' ) ;
153+ const isHost = localStorage . getItem ( `is_host_${ meetingId } ` ) === 'true' ;
154+ const userRole = isHost ? 'host' : 'participant' ;
155+ const candidateId = `place_${ String ( place . id ) . padStart ( 2 , '0' ) } ` ;
156+
157+ sendGAEvent ( 'event' , 'external_map_opened' , {
158+ meeting_url_id : meetingId ,
159+ user_cookie_id : browserId ,
160+ role : userRole ,
161+ candidate_id : candidateId ,
162+ } ) ;
163+ }
164+
144165 if ( placeUrl ) {
145166 window . open ( placeUrl , '_blank' , 'noopener,noreferrer' ) ;
146167 } else {
147168 window . open ( 'https://map.kakao.com' , '_blank' , 'noopener,noreferrer' ) ;
148169 }
149170 } ;
150171
172+ // 장소 리스트 중 하나 클릭 시 GA 전송 (place_list_viewed)
173+ const handlePlaceClick = ( place : ( typeof places ) [ 0 ] ) => {
174+ setSelectedPlaceId ( place . id ) ;
175+ if ( meetingId ) {
176+ const candidateId = `place_${ String ( place . id ) . padStart ( 2 , '0' ) } ` ;
177+ sendGAEvent ( 'event' , 'place_list_viewed' , {
178+ meeting_url_id : meetingId ,
179+ candidate_id : candidateId ,
180+ place_category : place . category ,
181+ rank_order : place . id ,
182+ } ) ;
183+ }
184+ } ;
185+
151186 return (
152187 < div className = "flex items-center justify-center p-0 md:min-h-[calc(100vh-200px)] md:py-25" >
153188 < div className = "flex h-full w-full flex-col bg-white md:h-175 md:w-174 md:flex-row md:gap-2 lg:w-215" >
@@ -194,7 +229,7 @@ function RecommendContent() {
194229 { places . map ( ( place ) => (
195230 < div
196231 key = { place . id }
197- onClick = { ( ) => setSelectedPlaceId ( place . id ) }
232+ onClick = { ( ) => handlePlaceClick ( place ) }
198233 className = { `flex cursor-pointer flex-col gap-2 rounded border p-4 ${
199234 selectedPlaceId === place . id
200235 ? 'border-blue-5 border-2'
@@ -247,7 +282,7 @@ function RecommendContent() {
247282 { /* 하단 버튼은 조건부 렌더링 */ }
248283 { selectedPlaceId === place . id ? (
249284 < button
250- onClick = { ( e ) => handleOpenKakaoMap ( e , place . placeUrl ) }
285+ onClick = { ( e ) => handleOpenKakaoMap ( e , place . placeUrl , place ) }
251286 className = "bg-gray-8 w-full rounded py-2 text-[15px] text-white"
252287 >
253288 카카오맵에서 보기
0 commit comments