使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
选择注册流程
集成 AFP 时,您要做的一个重要决定是选择注册流程,以便用户开始使用。注册的目的在于,让您的用户能够创建新的 AdSense 账号(或登录现有 AdSense 账号)并将相应账号关联到您的平台。您做出的选择将取决于您要在开发方面投入的技术资源以及您要为用户提供的新手入门体验。
选项 1:无需 API 的流程
选项 1 不使用 API,因此几乎不需要技术资源。只需一位 Web 开发者即可在您的平台中构建界面。但需要权衡的是,选择此选项后,您的用户需要执行更多步骤才能完成注册流程。
无需 API 的注册流程概览

实现
若要实现无需 API 的注册流程,您需要提供用于 AdSense 创收的界面组件。例如,在您的用户访问其“用户个人资料”或“账号设置”的页面上,添加一个包含以下内容的创收页面:
- 有关 AdSense 及其如何与您的平台互动的简短说明。用户应该完全清楚,他们是要注册新的 AdSense 账号,还是使用其现有 AdSense 账号。
- 有关 AdSense 合作规范的信息。所有注册用户都应了解 AdSense 计划及其合作规范。
- 您的用户将获得的收益分成。请务必向用户明确显示您和发布商将分别获得的 AdSense 收入所占百分比。在新手入门流程期间,AdSense 还将额外展示此信息。
- “关联 AdSense”按钮。点击此按钮后,系统将打开一个新的标签页,并根据用户是否已有 AdSense 账号将其转到 AdSense 中正确的页面。
自定义网址示例:
https://adsense.google.com/adsense/signup?url={platform-site-url}
注意:Google 将向您提供自定义注册页面的网址,并帮助您定义网址变量的内容。
- 用于收集和存储用户的 AdSense 发布商 ID 的输入框。在访问上面的链接后,用户需要将其发布商 ID 复制并粘贴到此输入框中。
重要提示:请务必存储用户的发布商 ID,这样您就可以使用正确的发布商信息为用户的内容页添加代码。如需了解详情,请参阅向您的网页添加广告代码。
请务必验证输入的字符串。发布商 ID 的格式为:pub-1234567890987654
也可以采用正则表达式的形式:pub\-\d{16}
重要提示:部分 AdSense 用户无需点击“关联 AdSense”按钮即可粘贴其发布商 ID。请务必告知用户,他们需要在其 AdSense 账号的网站页面中列出平台网域,然后广告才能投放。这是此按钮的主要用途。
- 用户的代码植入状态。用户会希望了解他们的广告代码是否已放置在其网页上。为了提供良好的用户体验,当您使用用户的 AdSense 发布商 ID 为他们的网页添加代码后,请告知他们。此外,您还可以填充子账号元标记,这有助于 AdSense 在网站验证步骤中顺利完成验证。这样一来,您就不必再代表用户在其网页上发布广告代码。
选项 2:API 半辅助流程
选项 2 会使用 AdSense Management API 略微简化注册流程。该选项需要更多技术资源,但减少了用户完成 AdSense 注册所需执行的步骤。
API 半辅助流程概览

实现
若要通过 API 实现半辅助注册流程,您需要提供用于 AdSense 创收的界面组件。例如,在您的用户访问其“用户个人资料”或“账号设置”的页面上,添加一个包含以下内容的创收页面:
- 有关 AdSense 及其如何与您的平台互动的简短说明。用户应该完全清楚,他们是要注册 Google AdSense 账号,还是使用其现有 AdSense 账号。
- 有关 AdSense 合作规范的信息。所有注册用户都应了解 AdSense 计划及其合作规范。
- 您的用户将获得的收益分成。请务必向用户明确显示您和发布商将分别获得的 AdSense 收入所占百分比。在新手入门流程期间,AdSense 还将额外展示此信息。
- “关联 AdSense”按钮。点击此按钮后,系统将授权您作为平台来使用 AdSense Management API 访问 AdSense 客户的账号信息。请参阅我们的开发者文档,按照相关说明进行设置。借助此 API,您可以执行接下来的两个步骤。
- 使用 AdSense Management API 收集用户的 AdSense 发布商 ID。请务必验证输入的字符串。
发布商 ID 的格式为:pub-1234567890987654
也可以采用正则表达式的形式:pub\-\d{16}
重要提示:请务必存储用户的发布商 ID,这样您就可以使用正确的发布商信息为用户的内容页添加代码。如需了解详情,请参阅向您的网页添加广告代码。
- 使用 AdSense Management API 检查用户是否已将平台网站添加到他们的 AdSense 账号。如果没有添加,请用户点击下面的链接,完成相关设置。您应在此 API 中检查的网站名称是以下链接中的
{platform-site-url}
变量。
https://adsense.google.com/adsense/signup?url={platform-site-url}
注意:Google 将向您提供自定义注册页面的网址,并帮助您定义 url 变量的内容。
- - 用户的代码植入状态。用户会希望了解他们的广告代码是否已放置在其网页上。为了提供良好的用户体验,当您使用用户的 AdSense 发布商 ID 为他们的网页添加代码后,请告知他们。此外,您还可以填充子账号元标记,这有助于 AdSense 在网站验证步骤中顺利完成验证。这样一来,您就不必再代表用户在其网页上发布广告代码。
选项 3:嵌入式 Connect
嵌入式 Connect 消除了处理不同状态 AdSense 账号的所有复杂性。根据给定用户的 AdSense 账号的账号、广告客户和网站状态,嵌入式 Connect 流程会为每位用户提供量身定制的初始配置体验,这样您就不必操心了。

实现涉及一个 JavaScript 库、一个空白 div(AdSense 将在其中呈现注册 widget),以及一些回调函数,这些函数可让您在用户完成注册流程后保存发布商 ID。您还可以使用 AdSense Management API 来增强使用体验,例如检索广告单元或自动广告的状态。
详细了解嵌入式 Connect
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
[null,null,[],[[["\u003cp\u003eAdSense for Platforms (AFP) offers three signup flow options to onboard users, each with varying technical requirements and user experiences.\u003c/p\u003e\n"],["\u003cp\u003eThe API-less flow is the simplest to implement but requires more user steps; the Semi-assisted API flow utilizes the AdSense Management API for a smoother experience; and Embedded Connect provides a fully customized and automated signup process.\u003c/p\u003e\n"],["\u003cp\u003eAll signup flows necessitate clear communication with users about AdSense policies, revenue share, and tagging status, ensuring transparency and understanding.\u003c/p\u003e\n"],["\u003cp\u003eRegardless of the chosen flow, securely storing the user's AdSense Publisher ID is crucial for proper ad serving and revenue tracking.\u003c/p\u003e\n"],["\u003cp\u003eAFP provides flexibility for platforms to tailor the signup experience to their specific needs and technical capabilities while adhering to AdSense guidelines.\u003c/p\u003e\n"]]],["The document outlines three signup flows for integrating AdSense into a platform. The API-less flow requires users to manually connect their AdSense account via a link and input their publisher ID. The semi-assisted API flow utilizes the AdSense Management API to retrieve the user's publisher ID and check their site status, reducing user steps. Embedded Connect, a third option, uses a JavaScript library for a streamlined experience and handles complex account states automatically. All options involve displaying AdSense policies and revenue sharing information.\n"],null,["Choose a sign up flow\n---------------------\n\nAn important decision with AFP is to choose a sign up flow to onboard your users. The purpose of the sign up is to allow your users to create a new AdSense account (or sign in to an existing AdSense account) and link it to your platform. The option you choose will depend on the technical resources you want to invest in development and the onboarding experience you want to provide for your users.\n\n### Option 1: API-less flow\n\nOption 1 requires the fewest technical resources as it doesn't use an API. You will only need a web developer to build the user interface within your platform. However, the trade-off is that this option requires your users to take more steps to complete the signup flow.\n\n#### Overview of the API-less signup flow\n\n#### Implementation\n\nTo implement an API-less signup flow, you need to provide a UI component for AdSense monetization. For example, on the page where your users access their \"user profile\" or \"account settings\", add a monetization page that includes the following:\n\n- A short description of AdSense and how it interacts with your platform. Users should be completely aware that they're either signing up for a new AdSense account or using their existing AdSense account.\n- Information about the [AdSense Program policies](https://support.google.com/adsense/answer/48182). All users who sign up should be aware of the AdSense Program and its policies.\n- The revenue share that your users will receive. It's important to explicitly show users what percentage of the AdSense revenue you will keep and what percentage the publisher will keep. AdSense will additionally show this information during the onboarding flow.\n- A \"Connect AdSense\" button. This button will open a new tab and take the user to the correct page in AdSense depending on whether or not they have an existing AdSense account. \n Example custom URL: \n `https://adsense.google.com/adsense/signup?url={platform-site-url}` \n **Note:** Google will provide you with the URL of the custom signup page, and help you define the contents of the URL variable.\n- An input box to collect and store the user's AdSense publisher ID. After a user visits the link above, they will need to copy and paste their publisher ID into this input box. \n **Important:** It's critical that you store the user's publisher ID so that you can tag the user's content pages with the correct publisher information. See the [Add the ad tag to your pages](/adsense/platforms/transparent/ad-tags) for more information. \n Make sure you validate the inputted string. The format of a publisher ID is: `pub-1234567890987654` \n Or in regex terms: `pub\\-\\d{16}` \n **Important:** Some AdSense users may paste their publisher ID without clicking on the \"Connect AdSense\" button. It's important to let users know that the **Sites** page in their AdSense account needs to have the platform domain listed before ads can be served. This is the primary purpose of this button.\n- The user's tagging status. Users will want to know whether their ad code has been placed on their pages or not. As part of the user experience, let your users know when you've tagged their pages with their AdSense publisher ID. You can additionally populate the [child account meta tag](/adsense/platforms/transparent/meta-tags#child_account) which will assist AdSense during the site verification steps. This also removes the need to publish ad tags on their pages on the user's behalf.\n\n### Option 2: Semi-assisted API flow\n\nOption 2 uses the [AdSense Management API](https://developers.google.com/adsense/management) to slightly simplify the signup flow. It requires more technical resources but reduces the number of steps your users need to take to sign up for AdSense.\n\n#### Overview of the semi-assisted API flow\n\n#### Implementation\n\nTo implement a semi-assisted signup flow with an API, you need to provide a UI component for AdSense monetization. For example, on the page where your users access their \"user profile\" or \"account settings\", add a monetization page that includes the following:\n\n- A short description of AdSense and how it interacts with your platform. Users should be completely aware that they are signing up for a Google AdSense account, or using their existing AdSense account.\n- Information about the [AdSense Program policies](https://support.google.com/adsense/answer/48182). All users who sign up should be aware of the AdSense Program and its policies.\n- The revenue share that your users will receive. It's important to explicitly show users what percentage of the AdSense revenue you will keep and what percentage the publisher will keep. AdSense will additionally show this information during the onboarding flow.\n- A \"Connect AdSense\" button. This button will authorize you as the platform to access an AdSense customer's account information using the [AdSense Management API](https://developers.google.com/adsense/management). Please follow the instructions on our developer documentation to set this up. Using this API you can perform the next two steps.\n- Use the AdSense Management API to collect the user's AdSense publisher ID. Make sure you validate the inputted string. \n The format of a publisher ID is: `pub-1234567890987654` \n Or in regex terms: `pub\\-\\d{16}` \n **Important:** It's critical that you store the user's publisher ID so that you can tag the user's content pages with the correct publisher information. See the See the [Add the ad tag to your pages](/adsense/platforms/transparent/ad-tags) for more information.\n- Use the AdSense Management API to check if the user has added the platform site to their AdSense account. If not, ask the user to follow the link below to complete the set up. The name of the site you should check for in the API is the `{platform-site-url}` variable in the link below. \n `https://adsense.google.com/adsense/signup?url={platform-site-url}` \n **Note:** Google will provide you with the URL of the custom signup page, and help you define the contents of the url variable.\n- - The user's tagging status. Users will want to know whether their ad code has been placed on their pages or not. As part of the user experience, let your users know when you've tagged their pages with their AdSense publisher ID. You can additionally populate the [child account meta tag](/adsense/platforms/transparent/meta-tags#child_account) which will assist AdSense during the site verification steps. This also removes the need to publish ad tags on their pages on the user's behalf.\n\n### Option 3: Embedded Connect\n\nEmbedded Connect removes all the complexity of dealing with AdSense accounts in different states. Depending on the account, ad client and site statuses for a given user's AdSense account, the Embedded Connect flow will present a customized onboarding experience for each user so that you don't have to.\n\nThe implementation involves a JavaScript library, an empty div where AdSense will render a sign-up widget, and some callback functions which will allow you to save the publisher ID once the user has completed the sign-up flow. You can supplementally use the [AdSense Management API](/adsense/management) to augment the experience, for example by retrieving ad units or the state of Auto ads.\n\n[Learn more about Embedded Connect](/adsense/platforms/transparent/embedded-connect)"]]