筹划您的代码设置
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
在添加代码之前,您应该先查看现有的网站或应用配置,并分析哪些衡量产品以及衡量方面的实践可能已经落实到位。需要考虑的一些问题包括:
衡量目标
在开始设置任何衡量产品之前,请先考虑您的业务目标是什么。一些业务目标示例可能包括:
- 用户点击广告的频率
- 广告系列带来的新订阅量
- 转化为购物车结账的网站访问次数
- 您最成功的营销渠道
- 为了尽可能提高转化概率,界面元素的最佳放置位置
- 在网站的电子商务漏斗中表现最佳的产品
- 用户成功转化前通常会采取的行动
还可以考虑排除性目标,方法是确定与上述目标相反的情况。例如,确定难以产生转化的营销渠道就是一种相关的排除性目标,此类目标有助于您改善整体营销工作。
您可以根据业务目标来决定要使用的产品、要衡量的事件、可能需要的插桩以及要查看的报告。这些决策应有助于您制定衡量实现策略。
请注意,业务目标并非一成不变,需要您经常重新评估。随着您收集的数据越来越多,可能还会出现更多业务问题,您也需要根据这些问题调整实现策略。
Google 跟踪代码管理器、Google 代码还是 Firebase?
如果您刚开始接触代码植入,可能会问:我应该使用哪个平台?是 Google 代码、Google 跟踪代码管理器还是 Firebase?
如果您的网站平台或内容管理系统允许,则在部署分析和营销代码时,应首选 Google 跟踪代码管理器。跟踪代码管理器为您提供了极高的灵活性,可让您自主选择部署网站代码的方式和时间。即使您只需要在单一 Google 产品(例如 Google Ads)中使用,跟踪代码管理器也会为您制定衡量计划,为您将来可能进行的产品集成做好准备。
Google 代码:如果您还没有为网页添加过代码,或者只打算针对某一产品(如 Google Ads)为网页添加代码并希望随着时间的推移做出极少的更改,那么添加 Google 代码可能是最快速、最便捷的入门方法。Google 代码是可以添加到网页的一段代码。详细了解如何添加 Google 代码。
Google 跟踪代码管理器:跟踪代码管理器是一款功能强大且齐全的企业级跟踪代码管理系统,支持适用于网站和移动应用的 Google 代码、第三方跟踪代码和自定义代码。您可以通过跟踪代码管理器界面添加和修改代码,而无需在您的网站上调整源代码。此外,跟踪代码管理器还支持第三方跟踪代码、管理功能、版本控制,以及企业协作和安全功能。跟踪代码管理器让您能够创建可与团队共享的自定义代码和变量模板,并且您可以在社区模板库中部署和使用模板。您可以使用服务器端代码植入将代码从客户端迁移到云端,从而在性能和安全性方面获得额外的优势。详细了解跟踪代码管理器。
Firebase:Firebase 是 Google 推出的一个工具集,支持包括 iOS 和 Android 设备在内的移动设备。Firebase 包含 Google Ads 和 Google Analytics(分析)等 Google 产品的衡量框架。如果您需要在移动应用中设置衡量功能,请使用 Firebase。
您的衡量目标可能有助于您了解应该使用哪种代码植入工具:
- 如果您的主要衡量目标与 Google Ads 效果相关,不妨考虑使用 Google 代码。
- 如果您的主要目标是衡量网站的所有流量,不妨考虑使用 Google 代码。
- 如果您想衡量 Google Ads、Google Analytics(分析)和其他衡量平台,不妨考虑使用 Google 跟踪代码管理器。
- 如果您想衡量移动设备上的广告系列效果和使用情况,请使用 Firebase。
无论您的衡量目标是什么,都可以考虑安装 Google 跟踪代码管理器,因为该工具可让您以非常灵活的方式使用一系列 Google(和第三方)衡量和广告产品。
与内容管理系统和电子商务系统集成
许多内容管理系统和电子商务系统都会提供与 Google 衡量产品的开箱即用型集成。在平台模板中继续添加 Google 代码段或安装 Google 跟踪代码管理器之前,请参阅提供商的支持文档,看看您的平台是否已内置 Google 代码的集成。
请注意,这些集成往往缺少它们所代表的测量堆栈的关键功能和最新更新。请务必查看相关文档,并根据需要咨询平台支持团队。
第三方跟踪代码管理系统
Google 代码通常通过第三方跟踪代码管理系统进行部署。使用第三方跟踪代码管理平台时,不论在何种情况下,您都需要参阅 Google 代码版的 Google 代码文档,并且应尽可能参阅第三方供应商的文档。
现有代码添加和插桩
请考虑一下您可能已经安装了哪些代码设置。如果您已添加和部署代码,则应查看代码配置,确保其已正确配置和优化。如果您使用的是旧版代码库(例如 analytics.js 或 conversions.js),则应将代码设置升级到支持的最新方法。您应避免添加冗余的代码或安装冗余的跟踪代码管理系统,并且应尽量确保代码配置尽可能高效。
如果想要了解网站的现有代码配置,最快捷的方法就是使用 Google Tag Assistant。运行 Tag Assistant 即可自动发现代码配置和产品 ID。
您还可以在源代码中手动搜索现有代码。
如果您已有代码平台,则还需要调查所有现有插桩。
- 是否已有
dataLayer
对象?如果是,该对象中包含哪些数据?
- 事件数据是否会显示在您的报告中?如果是,是哪些事件数据?
- 事件数据是如何收集的?
详细了解如何分析现有代码配置。
对于 Google 跟踪代码管理器安装
安装跟踪代码管理器时还需考虑其他一些事项:
管理人员变动
首次设置跟踪代码管理器账号时,请制定一项策略来规定由谁负责长期管理账号,以及在团队成员角色变更时如何处理账号所有权。
请根据情况制定相关策略,使其在有人离开您的组织且已终止其账号凭据的情况下,有助于确保组织仍然对您的跟踪代码管理器账号拥有访问权限。有些组织会将管理员角色委托给多位用户。而其他组织会创建专用的主 Google 账号,专门供其组织管理跟踪代码管理器使用。请选择最适合您的系统。
每个组织一个跟踪代码管理器账号
为每个组织设置一个跟踪代码管理器账号。跟踪代码管理器账号应由需要管理代码的组织创建。例如,如果某代理机构代表贵公司管理代码,则贵公司应该创建跟踪代码管理器账号,然后将该代理机构的 Google 账号添加为用户。
通过额外的安全控制功能助力 IT 部门
贵公司的 IT 部门可能会对 Google 跟踪代码管理器提供的部署自由心存警惕。IT 部门可以部署额外的安全措施,例如内容安全政策、自定义限制和自定义模板政策。
利用区域管理访问权限
代理机构可以在跟踪代码管理器的“管理”部分中管理其客户的现有账号。多位用户可以管理同一 Google 跟踪代码管理器账号,而且账号管理员可以为每位用户授予不同的访问权限。Google 跟踪代码管理器 360 客户可以利用区域来添加和控制更多容器。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-02-06。
[null,null,["最后更新时间 (UTC):2024-02-06。"],[[["\u003cp\u003eBefore installing tags, analyze your website or app's current measurement setup and goals to determine the best approach.\u003c/p\u003e\n"],["\u003cp\u003eChoose Google Tag Manager for flexibility and future scalability, Google tag for simple setups, or Firebase for mobile apps.\u003c/p\u003e\n"],["\u003cp\u003eConsider existing tag configurations and instrumentation to avoid redundancy and optimize your setup.\u003c/p\u003e\n"],["\u003cp\u003eFor Google Tag Manager, plan for long-term account management, utilize a single account per organization, and empower IT with security controls.\u003c/p\u003e\n"]]],["Before setting up tags, analyze existing website configurations and measurement practices. Define business goals to guide decisions on which measurement products, events, and reports to prioritize. Choose between Google Tag Manager, Google tag, or Firebase based on these goals. Assess existing tag platforms and instrumentation, including `dataLayer` objects and event data. For Tag Manager, establish a strategy for account management, security, and access controls. Ensure efficient and non-redundant tag configurations, and upgrade to the latest tag methods if necessary.\n"],null,["# Plan your tag setup\n\nBefore you install tags, you should look at your existing website or app\nconfiguration and analyze what measurement products and practices might already\nbe in place. Some questions to consider include:\n\n- [What are your measurement goals](#measurement_goals)?\n- [Should you use Google Tag Manager, gtag.js, or\n Firebase](#gtm_gtag_fb)?\n- [Do you have existing tags installed through Tag Manager, Google tag,\n Firebase, or other platforms](#existing_tag_platforms_and_instrumentation)?\n- [What custom instrumentation exists currently to collect data](#existing_tag_platforms_and_instrumentation)? For example: Do you have a way to collect ecommerce data on your site or app?\n\nMeasurement goals\n-----------------\n\nBefore you begin any measurement product setup, consider what your business\ngoals are first. Some example goals for your business might include:\n\n- How often an ad is clicked\n- How many new subscriptions come from ad campaigns\n- How many site visits result in cart checkouts\n- What your most successful marketing channels are\n- What the optimal placement of user interface elements is for the highest conversion probability\n- Which products fare best in the ecommerce funnel of the website\n- What actions typically precede a successful conversion\n\nAlso consider negative goals by identifying the opposite of the above goals. For\nexample, identifying marketing channels that struggle to produce conversions is\na relevant negative goal to help you improve your overall marketing efforts.\n\nUse your business goals to help you decide what products to use, which events\nyou want to measure, what instrumentation you might need, and what reports you'd\nlike to see. These decisions should drive your measurement implementation\nstrategy.\n\nRemember that business goals are not set in stone; they're questions you need to\nre-evaluate frequently. As you collect more data, additional business questions\nmight emerge that you'll want to refine in your implementation strategy, too.\n\nGoogle Tag Manager, Google tag, or Firebase?\n--------------------------------------------\n\nIf you're new to tagging, you might be asking: What should I use - the Google\ntag, Google Tag Manager, or Firebase?\n\nIf your site platform or Content Management System permits it, Google Tag\nManager should be your first choice for deploying analytics and marketing tags.\nTag Manager gives you the most flexibility in how and when to deploy site tags.\nEven if you only need it for a single Google product (such as Google Ads), Tag\nManager prepares your measurement plan for possible future product integrations\nas well.\n\n**Google tag:** If you haven't tagged your web pages yet, or only intend to\ntag your pages for one product (e.g. Google Ads) with few changes over time,\nthen a Google tag installation may be the fastest and easiest method to get\nstarted. The Google tag is a snippet of code that you add to a web page.\n[Learn more about Google tag installation](/tag-platform/gtagjs/install).\n\n**Google Tag Manager:** Tag Manager is a robust, fully featured, enterprise-\ngrade tag management system that supports Google, third-party, and custom tags\nfor web and mobile apps. You can add and modify tags through the Tag Manager\ninterface without adjusting the code on your site. In addition, Tag Manager\nfeatures support for third-party tags, organization features, version control,\nand enterprise collaboration and security features. Tag Manager features the\nability to create [custom tag and variable templates](/tag-platform/tag-manager/templates) that you can share with your\nteam, and you can deploy and use templates in the\n[Community Template Gallery](http://tagmanager.google.com/gallery).\nYou can use [server-side tagging](/tag-platform/tag-manager/server-side) to move code out of the client side and into\nthe cloud for additional performance and security benefits.\n[Learn more about Tag Manager](/tag-platform/tag-manager).\n\n**Firebase** Firebase is a toolset by Google that supports mobile devices,\nincluding [iOS](https://firebase.google.com/docs/ios/setup) and [Android](https://firebase.google.com/docs/android/setup). Firebase includes measurement frameworks for\nGoogle products such as [Google Ads](https://firebase.google.com/docs/ads) and [Google Analytics](https://firebase.google.com/docs/analytics). Use Firebase if you\nneed to set up measurement on mobile apps.\n\nYour measurement goals may help to inform which tagging tool you should use:\n\n- If your primary measurement goal is related to Ads performance, consider using the Google tag.\n- If your primary goal is to measure all traffic to your site, consider using the Google tag.\n- If you want to measure Google Ads, Google Analytics, and other measurement platforms, consider using Google Tag Manager.\n- If you want to measure campaigns and usage on mobile devices, use Firebase.\n\nRegardless of your measurement goals, consider installing Google Tag Manager,\nas it gives you the most flexibility in working with a range of Google (and\nthird-party) measurement and advertising products.\n\nIntegration with content management and ecommerce systems\n---------------------------------------------------------\n\nMany content management and ecommerce systems feature turnkey integration with\nGoogle measurement products. Before you proceed with adding the Google tag snippet or\ninstalling Google Tag Manager in your platform's templates, see if your platform\nalready provides a built-in integration for Google tags by checking the\nprovider's support documentation.\n\nNote that often these integrations might be missing key features and latest\nupdates to the measurement stacks they represent. Be sure to check the\ndocumentation and consult platform support, if necessary.\n\nThird-party tag management systems\n----------------------------------\n\nGoogle tags are commonly deployed from third-party tag management systems. When\nusing a third-party tag management platform, in all cases you will want to refer\nto the Google tag version of Google's tag documentation, and whenever\npossible you should refer to the third-party vendor's documentation.\n\nExisting tag installations and instrumentation\n----------------------------------------------\n\nConsider what tag setups you may already have installed. If you have tags\nalready installed and deployed, you should review your tag configuration to\nensure it is properly configured and optimized. If you are on an older tag\nlibrary such as analytics.js or conversions.js, you should\n[upgrade your tag setup](/tag-platform/devguides/upgrade) to the latest supported method. You should avoid\ninstalling redundant tags or tag management systems, and you should try to keep\nyour tag configurations as efficient as possible.\n\nThe quickest way to figure out existing tag configurations for web sites is to\nuse [Google Tag Assistant](https://tagassistant.google.com/).\nRun Tag Assistant to automatically discover tag configurations and product IDs.\n\nYou can also manually search for existing tags in source code.\n\nIf there is an existing tag platform, you will also want to investigate any\nexisting instrumentation.\n\n- Is there an existing [`dataLayer`](/tag-platform/devguides/datalayer) object? If so, what data appears in it?\n- Does event data appear in your reports? If so, what?\n- How is event data being collected?\n\n[Learn more about analyzing existing tag configurations](/tag-platform/devguides/existing).\n\nFor Google Tag Manager installations\n------------------------------------\n\nTag Manager installations have additional considerations:\n\n### Manage personnel changes\n\nWhen you first [set up a Tag Manager account](https://support.google.com/tagmanager/answer/6103696), put a strategy in\nplace for who will manage the account over the long term, and to define how\naccount ownership will be handled should a member of your team change roles.\n\nHave a strategy that will help to ensure that if someone leaves your\norganization and their account credentials are terminated, the organization will\nmaintain access to your Tag Manager account. Some organizations delegate\n[administrator roles](https://support.google.com/tagmanager/answer/6107011) to multiple users. Others create a dedicated master Google\naccount just for Tag Manager administration for their organization. Choose the\nsystem that works best for you.\n\n### One Tag Manager account per organization\n\nSet up one Tag Manager account per organization. The organization for which the\ntags will be managed should create the Tag Manager account. For example, if an\nagency manages tags on behalf of your company, then your company should create\nthe Tag Manager account and add the agency's Google account as a user.\n\n### Empower IT with additional security controls\n\nYour company's IT department may be wary about the freedom of deployment that\nGoogle Tag Manager provides. IT can deploy additional security measures such as\n[Content Security Policies](/tag-platform/tag-manager/web/csp), [custom restrictions](/tag-platform/tag-manager/web/restrict), and\n[custom template policies](https://developers.google.com/tag-platform/tag-manager/templates/policies).\n\n### Use zones to manage access\n\nAgencies can manage their clients' existing accounts in the admin section of Tag\nManager. Multiple users can manage the same Google Tag Manager account, and each\nuser can be given different access permissions by the account administrators.\nGoogle Tag Manager 360 customers can add and control additional containers using\n[zones](https://support.google.com/tagmanager/answer/7647043)."]]