遷移至 Google 代碼管理工具
為了讓 Google 代碼管理工具發揮最高價值,建議您將所有現有代碼 (盡可能多) 遷移至代碼管理工具。建議步驟如下:
對應網站 (選用)
請想想您的網站目前可能部署哪些代碼。請思考您要追蹤的動作 (事件) 和想收集的資料 (變數)。建立標記對應關係、要收集的資料,以及要與這些標記建立關聯的事件或網頁。
在網站上安裝代碼管理工具程式碼
完成網站對應後,請在網站中安裝
代碼管理工具容器代碼並進行部署。詳情請參閱安裝指南。
新增事件和變數
使用事件指南中所述的方法自訂 Google 代碼管理工具的安裝作業。
在代碼管理工具中設定代碼及其相關觸發條件
您在網站上安插代碼管理工具後,就應該將代碼新增到使用者介面。「請勿」發布這些資料。只要使用適當的範本範本和觸發條件,即可在代碼管理工具中加入及設定您網站的代碼。進一步瞭解觸發條件。
最終遷移替換作業
最後一個步驟是同時替換舊代碼,並在 Google 代碼管理工具中發布代碼您必須在幾分鐘內完成以下動作:
- 以單一程式碼推送的方式移除網站代碼
- 確認推送作業成功後,按下容器版本的 [發布] 按鈕。
這個方法可能會導致資料出現些微落差,但初始交換作業完成後,就不會再出現差距。或者,您可以在此變更順序,並在網站變更正式上線之前,立即發布。這可能會導致輕微的一次性資料重複,而非小型的資料差距。
完成初始遷移至代碼管理工具的作業後,您可以透過代碼管理工具介面處理任何後續的代碼設定,無須變更程式碼。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-07-29 (世界標準時間)。
[null,null,["上次更新時間:2024-07-29 (世界標準時間)。"],[[["Migrate all existing website tags to Google Tag Manager for centralized management."],["Map your website's tags, data, and events for a smooth transition."],["Install Tag Manager code, add events and variables, and configure tags within the interface."],["Swap out old tags with the new Tag Manager setup to complete the migration."],["Manage future tag configurations without code changes through the Tag Manager interface."]]],["To utilize Google Tag Manager, migrate existing tags by mapping your site's tags, data, and events. Install the Tag Manager code, then customize it with events and variables. Configure tags and triggers within Tag Manager's interface. Lastly, simultaneously remove old site tags and publish the configured tags in Tag Manager, which you can do in a few minutes. After migration, future tag adjustments occur through Tag Manager's interface without code changes.\n"]]