代碼和 Google 代碼簡介
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
標記是指將程式碼片段 (稱為標記) 的片段新增到
您就可以瞭解自家網站的訪客,以及他們
與其互動
代碼是許多成效評估產品不可或缺的一環,包括 Google Ads、
Google Analytics 和許多第三方產品
想知道最熱門的網誌文章是否最受歡迎,
到達網頁 (或最熱門的產品) 透過標記收集的資料
協助你做出更明智的網站和行銷決策
開始使用 Google 代碼
Google 代碼是一段程式碼,可在 Google Ads、Google
Analytics 等類似的 Google 產品您不需要管理多個代碼
也可以在各個 Google 產品帳戶中使用 Google 代碼
並將代碼連結至多個目的地。
設定 Google 代碼
設定 Google 代碼的方式,取決於您網站的設定方式及
修改程式碼您可以在網站的下列任一
方法如下:
Google 代碼管理工具:這個代碼管理系統可讓您設定
用來管理網站上的代碼,完全不必修改程式碼。如要使用代碼管理工具
在網站的每個網頁加入 2 段程式碼。加入
您不需要大幅修改程式碼
請改用代碼管理工具網站設定及管理代碼。
gtag.js:這個 JavaScript 架構可讓您將網站資料傳送至
Google 成效評估產品。設定 gtag.js 時,您需要在
每個網頁上如要有效使用 gtag.js,您需要熟悉
變更網站上的 JavaScript
如果您使用網站製作工具或內容管理系統 (例如 Shopify、Wix 或
Wordpress、網站製作工具或內容管理系統提供的
。
如要在行動應用程式中設定評估和廣告代碼,請按照下列步驟操作:
使用 Google Analytics for Firebase SDK然後也可以
使用代碼管理工具在行動應用程式中修改及轉送資料。
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-25 (世界標準時間)。
[null,null,["上次更新時間:2025-07-25 (世界標準時間)。"],[[["\u003cp\u003eTagging involves adding code snippets to web pages to gather data on visitor behavior and site performance.\u003c/p\u003e\n"],["\u003cp\u003eThe Google tag streamlines tag management, allowing connection to multiple Google products with a single code snippet.\u003c/p\u003e\n"],["\u003cp\u003eImplementing tags can be done through Google Tag Manager or gtag.js, offering varying levels of coding involvement.\u003c/p\u003e\n"],["\u003cp\u003eWebsite builders and content management systems often provide integrations for simplified tag setup.\u003c/p\u003e\n"],["\u003cp\u003eMobile app tagging utilizes the Google Analytics for Firebase SDK and can be managed through Tag Manager.\u003c/p\u003e\n"]]],["Tagging involves adding code snippets to website pages to track user behavior and gain insights for informed decision-making. The Google tag, a unified code snippet, can be implemented across a website and connected to multiple Google products. Implementation methods include Google Tag Manager, which requires two code snippets and allows tag management without coding, and gtag.js, requiring one code snippet and JavaScript proficiency. Website builders and the Firebase SDK offer integrations for simplified implementation.\n"],null,["# Introduction to tagging and the Google tag\n\nTagging is the process of adding snippets of code (called tags) to each page of\nyour website so you can learn about the people who visit your site and how they\ninteract with it.\n\nTagging is an integral part of many measurement products, including Google Ads,\nGoogle Analytics, and many third-party products too.\n\nWhether you want to know about your most popular blog posts, most effective\nlanding pages, or most popular products, the data you'll collect through tagging\nlets you make more informed decisions about your site and your marketing\nstrategies.\n\nGet started with the Google tag\n-------------------------------\n\nThe Google tag is a single piece of code that you can find in Google Ads, Google\nAnalytics, and other similar Google products. Instead of managing multiple tags\nfor different Google product accounts, you can use the Google tag across your\nentire website and connect the tag to multiple destinations.\n\nSet up the Google tag\n---------------------\n\nSetting up the Google tag depends on how your site is set up and how you can\nchange the code. You can implement the Google tag on your site in one of the\nfollowing ways:\n\n- **Google Tag Manager**: A tag management system that lets you set up and\n manage tags on your site without changing your code. To use Tag Manager, you\n add 2 snippets of code to each page of your website. After you add the\n snippets to your code, you don't need to change your code much after that;\n instead, you can set up and manage your tags through the Tag Manager website.\n\n- **gtag.js**: A JavaScript framework that lets you send data from your site to\n Google measurement products. To set up gtag.js, you add 1 snippet of code to\n each page of your site. To use gtag.js effectively, you need to be comfortable\n changing JavaScript on your site.\n\nIf you use a website builder or content management system like Shopify, Wix, or\nWordpress, the website builder or content management system may offer an\nintegration for setting up Tag Manager or gtag.js on your site.\n\nTo set up measurement and advertising tags in a mobile app,\nuse the Google Analytics for Firebase SDK. Then, you can also\nuse Tag Manager to modify and route data in the mobile app.\n\nNext steps\n----------\n\n- [Plan your tag setup](/tag-platform/devguides/prerequisites)\n- Set up the Google tag with:\n - [Tag Manager](https://support.google.com/tagmanager/answer/6102821)\n - [gtag.js](/tag-platform/gtagjs/install)\n - [a website builder or CMS](https://support.google.com/tagmanager/answer/12403447)\n - [the Google Analytics for Firebase SDK](https://firebase.google.com/docs/analytics)"]]