Google Analytics 已在 2020 年推出新版,為用戶提供更多洞見。不過採用 Google Site Kit 的 WordPress 網站並不能採用一般方法升級。這裡這會詳細展示升級步驟。
Site Kit 暫不支援 Google Analytics 4
Google Analytics 4 由早前的「應用程式 + 網站」資源(App + Web property)中演變而成,不過為 WordPress 而設的 Site Kit 暫不支授 Google Analytics 4。因此採用 Site Kit 外掛的 WordPress 網站如需採用新版 Google Analytics,需要手動插入程式碼。
Site Kit 為 Google 官方為 WordPress 推出的外掛,能夠串連 Search Console、Analytics、Adsense 等服務。
WordPress Site Kit 教學 – Google 官方外掛整合 Search Console、GA 等服務
第一步:建立 GA 4 資源
首先前往 Google Analytics 的管理頁面,便可見到「升級至 GA 4」的選項。

然後選擇「開始使用」。

最後選擇「建立資源」。由於透過 Site Kit 或其他外掛為 WordPress 加入 Google Analytics 時,未必是使用 gtag.js,所以無法使用現有代碼收集資料供 GA4 的新資源使用。

完成!

查看 Google Analytics,可見除了既有以 UA 開首的資料之外,亦多一組新資源。

第二步:加入代碼
1:建立 Tag Manager
雖然已在 Google Analytics 建立 GA4 的資源,但由於網站仍未有相應的代碼收集資料,所以設定尚未完成。採用 Site Kit 的 WordPress 網站,可以直接連接 Tag Manger 服務,然後啟用 GA4 程式碼。

如同其他服務,Site Kit 會要求存取用戶帳戶。允許後就會自動返回 Site Kit 面頁。

如果仍未有 Tag Manager 帳戶,就要現在建立。

輸入基本資訊並同意條款,就可建立。


建立後,就會自動轉入 Tag Manger 頁面,並會提示用戶安裝程式碼。不過,由於我們採用 Site Kit,所以可以略過。

只要返回 Site Kit 設定頁「Re-fetch my Account」,就會選擇新增的 Tag Manager 容器。確認後繼續。

成功!

2:於 Tag Manager 加入 GA4 程式碼
之後,就可以到 Tag Manager 新增 GA4 程式碼。在左邊欄點選「代碼」,然後再按「新增」,進入代碼選項。

當中有「代碼設定」和「觸發條件」兩個設定。首先在「代碼設定」中,選擇「Google Analytics (分析):GA4 設定」(Configuration tag)

在評佔 ID 一欄輸入 GA4 資源的資源 ID,這可以在 Google Analytics 中找到。格式必須為 G-xxx。


返回 Tag Manager,輸入評估 ID。而在下面的觸發條件中,選擇「All pages」。

設定完成後,就可以儲存。

最後記得要提交,GA4 才會部署。

輸入版本名稱和說明後,就大功告成。

問與答
舊版的 Google Analytics 會繼續運作嗎?
通用 Analytics (UA 開首)仍會繼續收集資料,而舊有資料亦不會刪除。
GA 4 有甚麼新功能?
GA 4 將網站和手機程式的數據整合,讓用戶更了解訪客跨裝置的行為。在新的 GA 4 中,提供了更多報表。此外,GA 4 提供了更多活動記錄,如捲動、點擊等。