tags: 埋追蹤碼

追蹤碼埋設流程

廣告碼種類
GA (GOOGLE) : 查碼 UA、G- (新版)
ADS (GOOGLE):查碼AW
DV360(GOOGLE): 查碼DC
DSP、DMP (域動) : 查碼rtid
FB: 查碼 fb
Yahoo
Line


檢查追蹤碼
開F12查code
檢查pageview、usual 和ev(事件)
DSP、DMP檢查範例→ capmapping.htm?rtid=9339001、Documentcapmapping.htm?rtid=9339002
GA檢查範例→ t: pageview
DV360檢查範例→js?id=DC-10217099
FB檢查範例→ fbevents.js


產追蹤code
DSP→新增站點→填名稱、網址、行業別→

新增事件→將CODE貼到檔案
★用data-Admin帳號。

GA(舊版)→建立帳戶→管理→資源設定→設定客層和與趣表(打開)、使用加強連結歸因(打開)
追蹤資訊→資料收集→廣告報表功能(打開)
PV CODE:追蹤程式碼→將CODE貼到檔案(PV CODE)
事件CODE:目標→自訂→輸入事件名稱(中文描述)、選"事件"→填類別(填event)和動作(填function名稱)→貼gtag CODE 到事件檔裡改event 碼和 send_to碼

★隱藏設定裡設定舊版

gtag('event', 'CFreceive', {
'event_category': 'event',
'send_to': 'UA-173428589-1'
});

Google Ads
選專案 (沒專案請需求者創專案)

→工具設定→轉換→網站→填類別、轉換名稱、價值選"不為此轉…"→選自行轉換代碼→code(兩個)貼到pv檔(pv code)
網站→填類別、轉換名稱、價值選"不為此轉…"→選自行轉換代碼→code(僅事件)貼到事件檔(事件code)

Display&Video 360(DV360)
選專案 (沒專案請需求者創專案)
→新增→resources→floodlight→新增→web→填 name(中文)、format(Global)、type(counter)、Counting method(Standard)、Attribution(勾)、Remarketing(必勾)→code(兩個)貼到pv檔(pv code)
新增→resources→floodlight→新增→web→填 name、format(Global)、type(counter)、Counting method(Standard)、Attribution(勾)、Remarketing(必勾)→code貼到事件檔(事件code)

Line、FB、yahoo:追蹤code來自客戶給的檔


埋code
GTM
建立GTM容器code→ 建立帳戶→填帳戶名稱、容器名稱(客戶沒提供就用域動的網址)→點選網路→建立。

1.code給客戶埋(容器code)
將head和body 的 code 各自新增一支html檔案。檔名範例: 請將這段程式碼放在網頁最上方的 <head>

2.code幫客戶埋
pv碼設定: 工作區→代碼→新增→命名代碼、代碼設定(自訂HTML→將pv碼貼上→選擇觸發條件)→儲存
事件碼設定: 工作區→代碼→新增→命名代碼、代碼設定(自訂HTML→將事件碼貼上(function內的code)→選擇觸發條件→新增觸發條件→命名、觸發條件設定(所有元素→選部份點擊→選click Element、符合css選擇器、到客戶網站的事件點copy selector下來))→儲存

★pv click事件設置:

3.檢查埋碼有無成功

4.按"提交" (名稱範例:clickforce_v1)

★一般selector抓取元素點擊無效時的設定法↓

ps.表單需判斷不得為空才觸發事件code

<script>
  function CFsubmit() {
        clickforce_rtid("9379006");
        ElandTracker.Track({
            'source': 'CAP9379',
            'trackType': 'click',
            'trackSubfolderDepth': 3,
            'targetType': 'CFsubmit'
        });

        gtag('event', 'conversion', { 'send_to': 'AW-615551387/io6QCKbJ1t8BEJujwqUC' });

        gtag('event', 'CFsubmit', {
            'event_category': 'event',
            'send_to': 'UA-178755716-1'
        });
    }

    var submitGtm = document.getElementById('9527');
    submitGtm.addEventListener('click', function () {
        var nameValue = document.getElementById('form-field-name').value;
        var emailValue = document.getElementById('form-field-email').value;
        var telValue = document.getElementById('form-field-field_57e9c8f').value;

        if (nameValue !== '' &&  emailValue !== '' && telValue !== '') {
            CFsubmit();
        }
    });
</script>

追蹤碼範例檔案:
https://drive.google.com/file/d/1MMb7h_MfzsbOsg7PLAJ9RieMiTK_dDcE/view?usp=sharing