感谢您预览 Google 的新代码平台文档!此网站为公开 Beta 版。(
反馈)
全局网站代码简介
全局网站代码 (gtag.js) 是可植入到网站中的单一代码,方便您使用各种 Google 产品和服务。该代码可与 Google Ads、Campaign Manager、Display & Video 360、Search Ads 360 和 Google Analytics(分析)等产品配合使用。您无需管理适用于不同产品的多个代码,只需使用全局网站代码并在整个网站中植入一次全局网站代码即可。
益处
衡量转化情况和优化您在 Google 营销方面的投资所带来的价值的最佳方法,就是在您网站的每个网页上放置代码。在整个网站中植入全局网站代码后,您将获享诸多额外的益处和增强功能:
- 面向未来的转化衡量。在最新的功能和集成服务推出时及时从中获益,这样一来,您就可以在更改发生时更好地继续准确衡量转化情况。
- 以无代码方式管理代码。无需手动更改网页上的代码,即可在 Google 产品中启用衡量功能。
- 集成更快捷、更轻松。代码植入以及与 Google Analytics(分析)、优化工具和 Google Ads 等其他 Google 产品的集成得到了简化,更加简单。
- 转化衡量更准确。全局网站代码可帮助您在 Cookie 不可用时更准确地衡量转化情况,以及恢复由于行业因素而当前未观察到的转化。
简要步骤
使用全局网站代码的基本模式如下所示:
- 向您网站上的每个网页添加全局网站代码,并对其进行配置,使其能够与您要使用的每个 Google 产品配合使用。
- 使用
gtag()
命令捕获事件,并将数据发送到一个或多个产品,例如 Google Ads、Google Analytics(分析)等。
添加了代码之后,您可以将其配置为使用单一代码处理多个产品和插桩。
如需获取与 gtag.js 相关的具体产品文档,请参阅以下内容:
后续步骤
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2021-12-20 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"没有我需要的信息"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"太复杂/步骤太多"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"内容需要更新"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻译问题"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"示例/代码问题"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"易于理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"解决了我的问题"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]