ไม่ต้องมี JavaScript helper
displayed_device_models ถูก join เป็น comma-separated string ตั้งแต่ต้นทาง ใช้ {{DLV - displayed_device_models}} ได้ทันที
GTM BUILD SHEET / v1.0
คู่มือตั้งค่า Google Tag Manager ตาม data contract ของแอป เรียงลำดับจาก Variable → Trigger → Tag เพื่อให้ทีมสร้างและตรวจสอบได้โดยไม่ต้องตีความใหม่
ค้นหาชื่อ event, key หรือ tag เพื่อกรองรายการด้านล่าง
สร้างทุกตัวเป็น Data Layer Variable — Version 2 โดยใส่ Data Layer Variable Name ตาม key ด้านล่างแบบตรงตัว
| # | Data Layer key | ชื่อใน GTM | Type | ใช้ใน event |
|---|---|---|---|---|
| 01 | site_name | DLV - site_name | string | ทุก event · ค่าคงที่ subscription-portal |
| 02 | sso_id | DLV - sso_id | string | null | user_identity |
| 03 | user_id | DLV - user_id | string | null | ทุก event · ใช้เป็น GA4 User-ID |
| 04–08 | utm_source, utm_medium, utm_campaign, utm_term, utm_content | DLV - <utm key> | string | null | utm_params + ทุก event แบบ present-only |
| 09 | offering_id | DLV - offering_id | string | impression, dialog, success/failure, subscribe, confirm, shopee, retry |
| 10 | package_id | DLV - package_id | string | null | success, subscribe, confirm, purchase_cancel |
| 11–13 | order_id, failure_code, failure_message | DLV - <key> | string | null | purchase success / failure / retry |
| 14–16 | source_page, blocked_reason, displayed_package_count | DLV - <key> | string / enum / number | plan impression, subscribe, dialog actions |
| 17–20 | device_id, selected_device_model, displayed_device_count, displayed_device_models | DLV - <key> | string | null / number | purchase confirm/cancel, device list impression |
| 21–25 | subscription_id, device_uuid, purchase_id, service_name, displayed_plan_count | DLV - <key> | string | null / number | cancel subscription, receipt, plan impression |
| 26 | — | CONST - Measurement ID | Constant | G-XXXXXXX ของ GA4 property |
displayed_device_models ถูก join เป็น comma-separated string ตั้งแต่ต้นทาง ใช้ {{DLV - displayed_device_models}} ได้ทันที
Container ID อ่านจาก process.env.GTM_ID ใน server-side layout; GTM จึงโหลดเฉพาะ environment ที่กำหนดตัวแปรนี้
ทุกตัวเป็น Custom Event: ใส่ Event name ตรงตัวและไม่ต้องใช้ regex
| # | ชื่อ Trigger | Event name ที่ match | ความถี่ | ยิงเมื่อ |
|---|---|---|---|---|
| 01 | CE - user_identity | user_identity | 1×/session | ssoId เปลี่ยนจาก login/logout |
| 02 | CE - utm_params | utm_params | 1×/session | landing URL มี utm; ไม่มี utm ไม่ยิง |
| 03 | CE - plan_impression | plan_impression | 1×/page view | render การ์ดแผนเสร็จ แม้ count = 0 |
| 04–05 | CE - purchase_success / failure | purchase_success / purchase_failure | ทุกครั้ง | native IAP ตอบกลับสำเร็จ / ล้มเหลว |
| 06 | CE - subscribe_click | subscribe_click | ทุกครั้ง | กด Subscribe รวมเคสถูกบล็อก |
| 07–08 | CE - dialog_cancel_click / confirm_click | dialog_cancel_click / dialog_confirm_click | 1×/dialog | ปิด dialog / กด Confirm; รวม swipe และ overlay |
| 09 | CE - purchase_confirm_click | purchase_confirm_click | ทุกครั้ง | Confirm หน้าเลือกอุปกรณ์ |
| 10–11 | CE - cancel_subscription_click / download_receipt_click | cancel_subscription_click / download_receipt_click | ทุกครั้ง | ยืนยันยกเลิก / ดาวน์โหลดใบเสร็จ |
| 12–14 | CE - shopee_link_click / purchase_retry_click / purchase_cancel | shopee_link_click / purchase_retry_click / purchase_cancel | ทุกครั้ง | ลิงก์ Shopee / ลองใหม่ / ยกเลิก IAP dialog |
| 15 | CE - device_list_impression | device_list_impression | 1×/page view | รายการอุปกรณ์แสดงครบ แม้ count = 0 |
สร้าง Config ก่อนเสมอ แล้วสร้าง GA4 Event tag ที่อ้าง Trigger และ Variable ด้านบน
| # | ชื่อ Tag | Trigger | GA4 event | Event parameters |
|---|---|---|---|---|
| 00 | GA4 Config - Subscription Portal | Initialization - All Pages | config | Measurement ID = {{CONST - Measurement ID}}; User ID = {{DLV - user_id}}; user property: site_name |
| 01 | GA4 - User Identity | CE - user_identity | user_identity | sso_id, site_name |
| 02 | GA4 - UTM Params | CE - utm_params | utm_params | utm_source, utm_medium, utm_campaign, utm_term, utm_content, site_name |
| 03 | GA4 - Plan Impression | CE - plan_impression | plan_impression | offering_id, source_page, displayed_plan_count, site_name |
| 04 | GA4 - Purchase Success | CE - purchase_success | purchase_success | offering_id, package_id, order_id, site_name |
| 05–08 | GA4 - Purchase Failure / Subscribe Click / Dialog Cancel / Confirm | CE - matching event | purchase_failure, subscribe_click, dialog_*_click | ตาม contract: offering_id, failure fields, package/source/blocked fields, site_name |
| 09 | GA4 - Purchase Confirm Click | CE - purchase_confirm_click | purchase_confirm_click | offering_id, package_id, device_id, selected_device_model, displayed_device_count, displayed_device_models, site_name |
| 10–15 | GA4 - Cancel / Receipt / Shopee / Retry / Purchase Cancel / Device List | CE - matching event | cancel_subscription_click, download_receipt_click, shopee_link_click, purchase_retry_click, purchase_cancel, device_list_impression | ส่ง key ตาม event และ site_name ทุก tag |
ตั้ง {{DLV - user_id}} ในช่อง User ID ของ Google tag configuration เพื่อให้ทุก event สืบทอด identity ไม่ใช่ใส่เป็น event parameter เฉย ๆ
แอปเป็น SPA ใน WebView: ปิด “Send a page view event when this configuration loads” ใน tag Config หากไม่ต้องการยอด page_view เกินจริง
dialog_cancel_click รวมปุ่ม cancel, swipe down และ overlay tap; dialog หนึ่งครั้งจึงเป็น cancel หรือ confirm เพียง event เดียว
dialog_confirm_click จะมาคู่ shopee_link_click เสมอ หากวิเคราะห์ conversion ให้เลือกนับเพียงจุดเดียว
เปลี่ยน tag Purchase Success ให้ยิง GA4 recommended event purchase, map order_id → transaction_id และ offering_id → item_id
UTM ล่าสุดถูกแนบทุก event เฉพาะ key ที่มีค่า; ไม่จำเป็นต้อง map ซ้ำในทุก tag เว้นแต่ต้องใช้กับ conversion โดยตรง