TouchWebLinerLandingLogger
웹 랜딩 페이지 추적을 위한 로거 클래스입니다. UTM 파라미터 기반으로 새 세션을 판단합니다.
Import
ts
import { TouchWebLinerLandingLogger } from '@liner-engineering/orbit-app/analytics';초기화
ts
const landingLogger = new TouchWebLinerLandingLogger({
cookieDomain: '.liner.com',
logEvent: ampLogEvent,
checkIsLoginUser: async () => {
// 로그인 여부 확인 로직
const user = await getUser();
return !!user;
},
});생성자 파라미터
| 파라미터 | 타입 | 설명 |
|---|---|---|
cookieDomain | string | 쿠키 도메인 (예: '.liner.com') |
logEvent | (eventName: string, properties: object) => void | 이벤트 로깅 함수 |
checkIsLoginUser | () => Promise<boolean> | 로그인 여부 확인 함수 |
Methods
setSessionCookie
세션 데이터를 쿠키에 저장합니다.
ts
landingLogger.setSessionCookie({
utm_source: 'google',
utm_medium: 'cpc',
utm_campaign: 'summer_sale',
utm_term: 'liner',
utm_content: 'banner',
timestamp: Date.now(),
});getSessionCookie
저장된 세션 데이터를 반환합니다.
ts
const session = landingLogger.getSessionCookie();
// LandingSessionData | undefinedisNewSession (getter)
새 세션 여부를 판단합니다.
ts
const isNew = landingLogger.isNewSession;
// true | false판단 로직:
- 쿠키 없음 → 새 세션
- 쿠키 있음 + UTM 파라미터 있음 + UTM 변경됨 → 새 세션
- 쿠키 있음 + UTM 파라미터 없음 → 기존 세션 유지
logAndSetSessionCookie
touch_web_liner_landing 이벤트를 로깅하고 세션 쿠키를 설정합니다.
ts
landingLogger.logAndSetSessionCookie();로깅되는 속성:
source_full_url:document.referrer- UTM 파라미터 (
utm_source,utm_medium,utm_campaign,utm_term,utm_content)
LandingSessionData
ts
interface LandingSessionData {
utm_source: string;
utm_medium: string;
utm_campaign: string;
utm_term: string;
utm_content: string;
timestamp: number;
}사용 예시
tsx
import { TouchWebLinerLandingLogger } from '@liner-engineering/orbit-app/analytics';
const landingLogger = new TouchWebLinerLandingLogger({
cookieDomain: '.liner.com',
logEvent: ampLogEvent,
checkIsLoginUser: async () => {
return await isUserLoggedIn();
},
});
function App() {
useEffect(() => {
const logLanding = async () => {
const isLoginUser = await landingLogger.checkIsLoginUser();
// 비로그인 사용자이고 새 세션인 경우에만 로깅
if (!isLoginUser && landingLogger.isNewSession) {
landingLogger.logAndSetSessionCookie();
}
};
logLanding();
}, []);
return <YourApp />;
}쿠키 이름
쿠키 이름은 TOUCH_WEB_LINER_LANDING_DATA이며, 브라우저 세션 동안 유효합니다.
UTM 파라미터
URL의 UTM 파라미터가 변경되면 새 세션으로 판단합니다. 예: ?utm_source=google&utm_medium=cpc