您只需为自己的网站添加一种或多种代码,即可开始在 Google Analytics(分析)和 Google Ads 转化衡量等衡量及广告产品中收集数据。您可以使用 Google 代码 (gtag.js)(需要更改 JavaScript 代码)或 Google 跟踪代码管理器等跟踪代码管理系统(需要在代码管理系统中更改配置)来添加代码。
如果您要在移动应用中部署衡量代码和广告代码,则可以使用 Google Analytics for Firebase SDK。部署 SDK 后,您还可以使用 Google 跟踪代码管理器来修改和以路由方式发送数据。
什么是“代码”?
什么是 Google 代码?
什么是 Google 跟踪代码管理器?
在 Google 文档中,Google 代码示例包含 gtag.js 代码,而跟踪代码管理器示例提供了代码配置步骤。
用法示例
以下示例说明了 Google 代码用法与跟踪代码管理器用法之间的区别。
以下 Google 代码是可添加到您网站的每个网页中的代码段:通过该代码段中的代码 ID,可为 Google Analytics(分析)和 Google Ads 启用衡量功能。
<script async
src="https://www.googletagmanager.com/gtag/js?id=TAG_ID">
</script>
<script>
window.dataLayer = window.dataLayer || [] ;
function gtag(){dataLayer.push(arguments);}
gtag( 'js', new Date () ) ;
gtag( 'config', 'TAG_ID');
</script>
如需使用跟踪代码管理器为 Google Analytics(分析)和 Google Ads 启用衡量功能,您需要为 Google Analytics(分析)和 Google Ads 转化分别创建代码,然后将其配置为在同一触发器上触发。发布容器后,您可以立即在网站上看到更改。如需了解详情,请参阅 Google Ads 转化。
[null,null,["最后更新时间 (UTC):2024-02-06。"],[[["Tagging involves adding code snippets to web pages to gather data on visitor behavior and site performance."],["The Google tag streamlines tag management, allowing connection to multiple Google products with a single code snippet."],["Implementing tags can be done through Google Tag Manager or gtag.js, offering varying levels of coding involvement."],["Website builders and content management systems often provide integrations for simplified tag setup."],["Mobile app tagging utilizes the Google Analytics for Firebase SDK and can be managed through Tag Manager."]]],["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"]]