# Server-side GTM Guide sGTM 아키텍처 옵션 및 설정 가이드. ## Why Server-side GTM? | Benefit | Description | |---------|-------------| | Data Control | 클라이언트 → 서버 → 벤더 흐름 제어 | | Privacy | PII 필터링, 서버에서 처리 | | Cookie Duration | 1st-party cookie (최대 2년) | | Performance | 클라이언트 JS 감소 | | Reliability | Ad blocker 영향 최소화 | ## Architecture Options ### Option 1: GCP Cloud Run ``` Browser → Your Domain (1st-party) → GCP Cloud Run → GA4/Ads/Meta ``` - **Pros**: 완전한 제어, GCP 통합 - **Cons**: GCP 전문 지식 필요 - **Cost**: Low ~$20, Medium ~$100, High $200+/월 ### Option 2: Stape.io (Managed) ``` Browser → Stape CDN → Stape Server → GA4/Ads/Meta ``` - **Pros**: 간편 설정 (10분), 관리형, 한국 리전 - **Cons**: 월정액, 벤더 종속 - **Cost**: Starter $20, Business $50, Scale $150/월 ### Option 3: Google Tag Gateway ``` Browser → Google Gateway → Google Cloud (Managed) → GA4/Ads ``` - **Pros**: Google 관리형, 무료(제한적) - **Cons**: Google 태그만 지원, 제한된 커스터마이징 ## Selection Guide | Requirement | Recommendation | |-------------|----------------| | Google 태그만 | Tag Gateway | | 빠른 구현 | Stape.io | | 완전한 제어 | GCP Cloud Run | | Third-party 태그 (Meta 등) | Stape 또는 GCP | ## Client Configuration ### Web Container 설정 ```javascript gtag('config', 'G-XXXXXXXXXX', { 'server_container_url': 'https://gtm.yourdomain.com' }); ``` ### GTM GA4 Configuration Tag ``` Advanced Settings: Server container URL: https://gtm.yourdomain.com ``` ## Stape Quick Setup 1. **계정 생성**: stape.io 2. **Container 생성**: Region = Seoul (asia-northeast3) 3. **Custom Domain 연결** ``` DNS: gtm.example.com CNAME [stape-provided-address] ``` 4. **GTM Server Container ID 연결** 5. **Web Container 수정**: server_container_url 추가 ## Server Tags ### GA4 Tag ``` Measurement ID: G-XXXXXXXXXX Event Name: {{Event Name}} Event Parameters: {{Event Data}} ``` ### Google Ads Conversion ``` Conversion ID: AW-XXXXXXXXX Conversion Label: [Label] Enhanced Conversions: Enabled ``` ### Meta Conversions API ``` Pixel ID: [ID] API Access Token: [Token] Event Name: {{Event Name}} ``` ## Testing 1. **Preview Mode**: GTM Server Container → Preview 2. **Validation**: - Client → Server 요청 도달 - Server → Platform 전송 확인 - Cookie 설정 확인 (1st-party) - Latency < 200ms ## Common Issues | Issue | Solution | |-------|----------| | 요청 미도달 | CORS, Custom domain 확인 | | Cookie 미설정 | Same-site 정책, 도메인 확인 | | Timeout | 리전 최적화, 스케일링 |