前提条件
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
请遵循以下前提条件来实施动态再营销。
添加 Google 代码和再营销事件代码段
首先,为网站添加再营销代码。
您可以使用 conversion_action
字段的 TagSnippet
从 API 中检索 googleGlobalSiteTag
或 event_snippet
。
以下是手动在网站中嵌入代码的步骤:
获取 Google 代码和再营销事件代码段。
Google 代码会在您的网站上设置一个新 Cookie,用于收集将访问者引导至您网站的广告点击的相关信息,并将网站访问者添加到您 Google Ads 账号中的标准再营销名单。
为确保代码植入能够与动态再营销搭配使用,请在创建 Google Ads 代码数据源这一步中选择收集特定属性或参数,用以贴身定制个性化广告,如下所示:

如需详细了解如何获取 Google 代码和再营销事件代码段,请参阅使用 Google Ads 为网站添加代码。
添加 Google 代码。
您必须在网站上所有会发送再营销信息的网页上都添加 Google 代码,但每个 Google Ads 账号只需要一段 Google 代码。事件代码段可用于跟踪应计为再营销事件的其他操作。将此代码段添加到您要跟踪的网站网页上,紧跟在 <head></head>
部分中的 Google 代码之后。
Google 代码还可与其他代码(例如 Google Analytics 代码)搭配使用。
详细了解代码在 Google Analytics 中的运作方式。
在您要跟踪的网站网页上安装事件代码段,并提供相应的自定义参数值。
自定义参数是再营销代码中的元素,可让代码将您网站上特定商品或选择项的相关信息发送到您的 Google Ads 账号。自定义参数直接与商家数据 Feed 相关,您可以在其中添加与代码收集的信息相对应的值。
如需使用动态再营销,您需要使用标记为 Required
的自定义参数,如动态再营销事件和参数中所述。
将自定义参数的值添加到再营销代码后,该值会与您的 Feed 同步,以便在广告中展示同一位访问者之前浏览过的同一产品或服务。
以下示例展示了如何为零售网站安装事件代码段(请注意,ecomm_prodid
是与网页上的商品对应的 Merchant Center 商品 ID):
gtag('event', 'page_view', {
ecomm_pagetype: 'product',
ecomm_prodid: 34592212,
ecomm_totalvalue: 29.99,
ecomm_category: 'Home & Garden',
isSaleItem: false
});
如需详细了解参数及其有效值,请参阅动态再营销事件和参数。
您使用的事件名称(例如上述示例中的 page_view
)可以是您选择的自定义事件名称,也可以是我们推荐的标准事件之一。
为了实现动态再营销,此值无需与任何特定值匹配,只要事件数据参数(在此示例中为 ecomm_pagetype
、ecomm_prodid
和 ecomm_totalvalue
)设置正确即可。
如需详细了解不同业务类型的自定义参数以及 Google 代码的运作方式,请参阅为您的网站设置转化跟踪。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-26。
[null,null,["最后更新时间 (UTC):2025-08-26。"],[[["\u003cp\u003eInstall the Google tag and remarketing event snippet on all website pages to enable dynamic remarketing.\u003c/p\u003e\n"],["\u003cp\u003eWhen setting up the Google tag, ensure you select "Collect specific attributes or parameters to personalize ads" for dynamic remarketing functionality.\u003c/p\u003e\n"],["\u003cp\u003eUtilize custom parameters within the event snippet to send specific product or service information to your Google Ads account for targeted ads.\u003c/p\u003e\n"],["\u003cp\u003eEnsure the custom parameters, such as 'ecomm_prodid', align with your business data feeds for accurate product or service synchronization in ads.\u003c/p\u003e\n"]]],[],null,["# Prerequisites\n\nFollow these prerequisites to implement dynamic remarketing.\n\nInstall Google tag and remarketing event snippet\n------------------------------------------------\n\nBegin by\n[tagging your site for remarketing](//support.google.com/google-ads/answer/2476688).\nYou can retrieve the `googleGlobalSiteTag` or `event_snippet` from the API using\nthe [`TagSnippet`](/google-ads/api/reference/rpc/v21/TagSnippet) of the\n[`conversion_action`](/google-ads/api/fields/v21/conversion_action) field.\n\nHere are the steps for embedding tags in your website manually:\n\n1. **Get the Google tag and the remarketing event snippet.**\n\n The Google tag sets a new cookie on your site which collects information\n about the ad click that brought a visitor to your site and adds website\n visitors to standard remarketing lists in your Google Ads account.\n\n To make sure the tagging works with dynamic remarketing, select **Collect\n specific attributes or parameters to personalize ads** during the step\n **Create the Google Ads tag data source**, as shown below:\n\n For detailed instructions for acquiring the Google tag and remarketing event\n snippet, see\n [Tag your website using Google Ads](//support.google.com/google-ads/answer/2476688).\n2. **Install the Google tag.**\n\n You must install the Google tag on all the pages of your website that\n send remarketing information, but you need only one Google tag for each\n Google Ads account. The event snippet can be used to track additional actions\n that are to be counted as remarketing events. Install this snippet on site\n pages you'd like to track, right after the Google tag in the\n `\u003chead\u003e\u003c/head\u003e` section.\n\n The Google tag also works with other tags such as Google Analytics tags.\n [Read more about how tags work in Google\n Analytics](/analytics/devguides/collection/gtagjs).\n3. **Install an event snippet on site pages you would like to track, with\n corresponding custom parameter values.**\n\n Custom parameters are elements in your remarketing tag code that allow your\n tag to send information about specific items or selections on your website to\n your Google Ads account. Custom parameters are directly related to business\n data feeds, where you add the values that correspond to the information\n the tag collects.\n\n To use dynamic remarketing, you'll need to use the custom parameters marked\n as `Required`, as described in\n [Dynamic remarketing events and parameters](//support.google.com/google-ads/answer/7305793).\n\n When you add the value of a custom parameter to your remarketing tag,\n it will sync with your feed to show the same product or service in\n your ads previously viewed by the same visitor.\n\n Here is an example of how to install an event snippet for a retail site (note\n the `ecomm_prodid` is the [Merchant Center Product\n ID](//support.google.com/merchants/answer/7052112) that corresponds to the\n product on the page): \n\n gtag('event', 'page_view', {\n ecomm_pagetype: 'product',\n ecomm_prodid: 34592212,\n ecomm_totalvalue: 29.99,\n ecomm_category: 'Home & Garden',\n isSaleItem: false\n });\n\n For detailed definitions of the parameters and their valid values,\n see\n [Dynamic remarketing events and parameters](//support.google.com/google-ads/answer/7305793).\n\n The event name you use (such as `page_view` in the above example) can be a\n custom event name of your choosing or one of our recommended standard events.\n It doesn't need to match any specific value for the purpose of implementing\n dynamic remarketing, as long as the event data parameters (`ecomm_pagetype`,\n `ecomm_prodid`, and `ecomm_totalvalue` in this example) are correctly set.\n\n For detailed documentation on custom parameters for different business types\n and how the Google tag works, refer to\n [Set up conversion tracking for your website](//support.google.com/google-ads/answer/12216424)."]]