遷移至 Google 代碼管理工具
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
為了讓 Google 代碼管理工具發揮最高價值,建議您將所有現有代碼 (盡可能多) 遷移至代碼管理工具。建議步驟如下:
對應網站 (選用)
請想想您的網站目前可能部署哪些代碼。請思考您要追蹤的動作 (事件) 和想收集的資料 (變數)。建立標記對應關係、要收集的資料,以及要與這些標記建立關聯的事件或網頁。
在網站上安裝代碼管理工具程式碼
完成網站對應後,請在網站中安裝
代碼管理工具容器代碼並進行部署。詳情請參閱安裝指南。
新增事件和變數
使用事件指南中所述的方法自訂 Google 代碼管理工具的安裝作業。
在代碼管理工具中設定代碼及其相關觸發條件
您在網站上安插代碼管理工具後,就應該將代碼新增到使用者介面。「請勿」發布這些資料。只要使用適當的範本範本和觸發條件,即可在代碼管理工具中加入及設定您網站的代碼。進一步瞭解觸發條件。
最終遷移替換作業
最後一個步驟是同時替換舊代碼,並在 Google 代碼管理工具中發布代碼您必須在幾分鐘內完成以下動作:
- 以單一程式碼推送的方式移除網站代碼
- 確認推送作業成功後,按下容器版本的 [發布] 按鈕。
這個方法可能會導致資料出現些微落差,但初始交換作業完成後,就不會再出現差距。或者,您可以在此變更順序,並在網站變更正式上線之前,立即發布。這可能會導致輕微的一次性資料重複,而非小型的資料差距。
完成初始遷移至代碼管理工具的作業後,您可以透過代碼管理工具介面處理任何後續的代碼設定,無須變更程式碼。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-07-29 (世界標準時間)。
[null,null,["上次更新時間:2024-07-29 (世界標準時間)。"],[[["\u003cp\u003eMigrate all existing website tags to Google Tag Manager for centralized management.\u003c/p\u003e\n"],["\u003cp\u003eMap your website's tags, data, and events for a smooth transition.\u003c/p\u003e\n"],["\u003cp\u003eInstall Tag Manager code, add events and variables, and configure tags within the interface.\u003c/p\u003e\n"],["\u003cp\u003eSwap out old tags with the new Tag Manager setup to complete the migration.\u003c/p\u003e\n"],["\u003cp\u003eManage future tag configurations without code changes through the Tag Manager interface.\u003c/p\u003e\n"]]],["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"],null,["# Migrate to Google Tag Manager\n\nTo gain the most value from Google Tag Manager, you should migrate all (or as\nmany as possible) of your existing tags into Tag Manager. The recommended steps\nare as follows:\n\n1. **Map your site (optional)**\n\n Think about which tags you might currently have deployed on your site. Think\n about what actions (events) you want to track and what data (variables)\n you'll want to collect. Create a map of tags, the data to be collected, and\n which events or pages you want to associate with those tags.\n2. **Install the Tag Manager code on your site**\n\n Once you've mapped your site, install the Tag Manager container tag on your\n site and deploy it. Read the [installation guidance](https://support.google.com/tagmanager/answer/14842164) for more information.\n3. **Add Events and Variables**\n\n Customize your Google Tag Manager installation using the methods outlined in\n the [events guidance](/tag-platform/devguides/events).\n4. **Configure tags and their associated triggers in Tag Manager**\n\n Once Tag Manager is installed on your site, you should add your site tags to\n the user interface. DO *NOT* publish at this time. Simply add and configure\n the tags from your site in Tag Manager with appropriate tag templates and\n triggers. [Learn more about triggers](https://support.google.com/tagmanager/topic/7679384).\n5. **Final migration swap**\n\n The last step is where you simultaneously swap out your old tags and publish\n your tags in Google Tag Manager. Within a few minutes of each other, you'll\n want to:\n - Remove your site tags in a single code push\n - Once you know this push is successful, press the \"Publish\" button for your container version.\n\n This method might cause a small gap in data, but once the initial swap is\n complete, no more gaps will appear. Alternatively, you could swap the order\n here and publish shortly before your site changes go live. This might cause\n minor, one-time data duplication instead of a small data gap.\n\nAfter you've completed the initial migration to Tag Manager, any subsequent tag\nconfiguration needs can be handled without code changes via the Tag Manager\ninterface."]]