Stay organized with collectionsSave and categorize content based on your preferences.
Dynamic remarketing enables your campaign to serve ads tailored to a user's past
behaviour. When a user is added to a dynamic remarketing list, the ID of an
asset is also provided in the tracking pixel. When a user from the list sees
an ad, the content for the ad is dynamically rendered from the underlyingAssetSet.
This document describes the process for managing dynamic remarketing campaigns
with assets for dynamic content.
Create assets to serve in your dynamic remarketing campaign
You can use the API to manage assets that contain the custom content for your
ad. TheAssetcontains an ID which can be used in the
tracking pixel, together with the customized content to serve in the ad.
defcreate_asset(client:GoogleAdsClient,customer_id:str)->str:"""Creates a DynamicEducationAsset.See https://support.google.com/google-ads/answer/6053288?#zippy=%2Ceducationfor a detailed explanation of the field format.Args:client: an initialized GoogleAdsClient instance.customer_id: a client customer ID.Returns:The resource name for an asset."""# Creates an operation to add the asset.operation:AssetOperation=client.get_type("AssetOperation")asset:Asset=operation.create# The final_urls list must not be emptyasset.final_urls.append("https://www.example.com")education_asset:DynamicEducationAsset=asset.dynamic_education_asset# Defines meta-information about the school and program.education_asset.school_name="The University of Unknown"education_asset.address="Building 1, New York, 12345, USA"education_asset.program_name="BSc. Computer Science"education_asset.subject="Computer Science"education_asset.program_description="Slinging code for fun and profit!"# Sets up the program ID which is the ID that should be specified in the# tracking pixel.education_asset.program_id="bsc-cs-uofu"# Sets up the location ID which may additionally be specified in the# tracking pixel.education_asset.location_id="nyc"education_asset.image_url="https://gaagl.page.link/Eit5"education_asset.android_app_link=("android-app://com.example.android/http/example.com/gizmos?1234")education_asset.ios_app_link="exampleApp://content/page"education_asset.ios_app_store_id=123asset_service:AssetServiceClient=client.get_service("AssetService")response:MutateAssetsResponse=asset_service.mutate_assets(customer_id=customer_id,operations=[operation])resource_name:str=response.results[0].resource_nameprint(f"Created a dynamic education asset with resource name '{resource_name}'")returnresource_name
defcreate_asset(client,customer_id)# Creates a DynamicEducationAsset.# See https://support.google.com/google-ads/answer/6053288?#zippy=%2Ceducation for a# detailed explanation of the field format.# Creates an operation to add the asset.operation=client.operation.create_resource.assetdo|asset|asset.final_urls<<'https://www.example.com'asset.dynamic_education_asset=client.resource.dynamic_education_assetdo|dea|# Defines meta-information about the school and program.dea.school_name='The University of Unknown'dea.address='Building 1, New York, 12345, USA'dea.program_name='BSc. Computer Science'dea.subject='Computer Science'dea.program_description='Slinging code for fun and profit!'# Sets up the program ID which is the ID that should be specified in the# tracking pixel.dea.program_id='bsc-cs-uofu'# Sets up the location ID which may additionally be specified in the# tracking pixel.dea.location_id='nyc'dea.image_url='https://gaagl.page.link/Eit5'dea.android_app_link='android-app://com.example.android/http/example.com/gizmos?1234'dea.ios_app_link='exampleApp://content/page'dea.ios_app_store_id=123endend# Sends the mutate request.response=client.service.asset.mutate_assets(customer_id:customer_id,operations:[operation],)resource_name=response.results.first.resource_nameputs"Created a dynamic education asset with resource name '#{resource_name}'"resource_nameend
# Create a DynamicEducationAsset.# See https://support.google.com/google-ads/answer/6053288?#zippy=%2Ceducation# for a detailed explanation of the field format.my$education_asset=Google::Ads::GoogleAds::V21::Common::DynamicEducationAsset->new({# Define meta-information about the school and program.schoolName=>"The University of Unknown",address=>"Building 1, New York, 12345, USA",programName=>"BSc. Computer Science",subject=>"Computer Science",programDescription=>"Slinging code for fun and profit!",# Set up the program ID which is the ID that should be specified in the# tracking pixel.programId=>"bsc-cs-uofu",# Set up the location ID which may additionally be specified in the tracking pixel.locationId=>"nyc",imageUrl=>"https://gaagl.page.link/Eit5",androidAppLink=>"android-app://com.example.android/http/example.com/gizmos?1234",iosAppLink=>"exampleApp://content/page",iosAppStoreId=>123});my$asset=Google::Ads::GoogleAds::V21::Resources::Asset->new({dynamicEducationAsset=>$education_asset,finalUrls=>["https://www.example.com"]});# Create an operation to add the asset.my$operation=Google::Ads::GoogleAds::V21::Services::AssetService::AssetOperation->new({create=>$asset});# Send the mutate request.my$response=$api_client->AssetService()->mutate({customerId=>$customer_id,operations=>[$operation]});# Print some information about the response.my$resource_name=$response->{results}[0]{resourceName};printf"Created a dynamic education asset with resource name '%s'.\n",$resource_name;return$resource_name;
AnAssetSetrepresents the collection ofAssetobjects which can be used for dynamic remarketing
in a particular campaign. AnAssetSetcan be associated with many campaigns
that can reuse the same group of Assets as required. This is similar to how the
Google Ads UI lets you specify the "data feed" for a dynamic remarketing campaign.
The first step is to create a newAssetSetto house your assets.
defcreate_asset_set(client:GoogleAdsClient,customer_id:str)->str:"""Creates an AssetSet.The AssetSet will be used to link the dynamic remarketing assets to acampaign.Args:client: an initialized GoogleAdsClient instance.customer_id: a client customer ID.Returns:The resource name for an asset set."""# Creates an operation to create the asset set.operation:AssetSetOperation=client.get_type("AssetSetOperation")asset_set:AssetSet=operation.createasset_set.name=f"My dynamic remarketing assets{datetime.now()}"asset_set.type_=client.enums.AssetSetTypeEnum.DYNAMIC_EDUCATIONasset_set_service:AssetSetServiceClient=client.get_service("AssetSetService")response:MutateAssetSetsResponse=asset_set_service.mutate_asset_sets(customer_id=customer_id,operations=[operation])resource_name:str=response.results[0].resource_nameprint(f"Created asset set with resource name '{resource_name}'")returnresource_name
defcreate_asset_set(client,customer_id)# Creates an AssetSet which will be used to link the dynamic remarketing assets to a campaign.# Creates an operation to add the asset set.operation=client.operation.create_resource.asset_setdo|asset_set|asset_set.name="My dynamic remarketing assets#{Time.now}"asset_set.type=:DYNAMIC_EDUCATIONend# Sends the mutate request.response=client.service.asset_set.mutate_asset_sets(customer_id:customer_id,operations:[operation],)resource_name=response.results.first.resource_nameputs"Created asset set with resource name '#{resource_name}'"resource_nameend
# Create an AssetSet which will be used to link the dynamic remarketing assets# to a campaign.my$asset_set=Google::Ads::GoogleAds::V21::Resources::AssetSet->new({name=>"My dynamic remarketing assets #".uniqid(),type=>DYNAMIC_EDUCATION});# Create an operation to add the AssetSet.my$operation=Google::Ads::GoogleAds::V21::Services::AssetSetService::AssetSetOperation->new({create=>$asset_set});# Send the mutate request.my$response=$api_client->AssetSetService()->mutate({customerId=>$customer_id,operations=>[$operation]});# Print some information about the response.my$resource_name=$response->{results}[0]{resourceName};printf"Created asset set with resource name '%s'.\n",$resource_name;return$resource_name;
defadd_assets_to_asset_set(client:GoogleAdsClient,asset_resource_name:str,asset_set_resource_name:str,customer_id:str,)->None:"""Adds an Asset to an AssetSet by creating an AssetSetAsset link.Args:client: an initialized GoogleAdsClient instance.asset_set_resource_name; the resource name for an asset set.asset_resource_name; the resource name for an asset.customer_id: a client customer ID."""# Creates an operation to add the asset set asset.operation:AssetSetAssetOperation=client.get_type("AssetSetAssetOperation")asset_set_asset:AssetSetAsset=operation.createasset_set_asset.asset=asset_resource_nameasset_set_asset.asset_set=asset_set_resource_nameasset_set_asset_service:AssetSetAssetServiceClient=client.get_service("AssetSetAssetService")# Note this is the point that the API will enforce uniqueness of the# DynamicEducationAsset.program_id field. You can have any number of assets# with the same program ID, however, only one asset is allowed per asset set# with the same program ID.response:MutateAssetSetAssetsResponse=(asset_set_asset_service.mutate_asset_set_assets(customer_id=customer_id,operations=[operation]))resource_name:str=response.results[0].resource_nameprint(f"Created asset set asset link with resource name '{resource_name}'")
defadd_assets_to_asset_set(client,asset_resource_name,asset_set_resource_name,customer_id)# Creates an operation to add the asset set asset.operation=client.operation.create_resource.asset_set_assetdo|asa|asa.asset=asset_resource_nameasa.asset_set=asset_set_resource_nameend# Sends the mutate request.## Note this is the point that the API will enforce uniqueness of the# DynamicEducationAsset.program_id field. You can have any number of assets# with the same program ID, however, only one asset is allowed per asset set# with the same program ID.response=client.service.asset_set_asset.mutate_asset_set_assets(customer_id:customer_id,operations:[operation],)resource_name=response.results.first.resource_nameputs"Created asset set asset link with resource name '#{resource_name}'"end
my$asset_set_asset=Google::Ads::GoogleAds::V21::Resources::AssetSetAsset->new({asset=>$asset_resource_name,assetSet=>$asset_set_resource_name});# Create an operation to add the link.my$operation=Google::Ads::GoogleAds::V21::Services::AssetSetAssetService::AssetSetAssetOperation->new({create=>$asset_set_asset});# Send the mutate request.# Note this is the point that the API will enforce uniqueness of the# DynamicEducationAsset.programId field. You can have any number of assets# with the same programId, however, only one Asset is allowed per AssetSet# with the same program ID.my$response=$api_client->AssetSetAssetService()->mutate({customerId=>$customer_id,operations=>[$operation]});# Print some information about the response.my$resource_name=$response->{results}[0]{resourceName};printf"Created AssetSetAsset link with resource name '%s'.\n",$resource_name;
Link the AssetSet to your campaign with CampaignAssetSet
Now that you have anAssetSetcontaining your
dynamic content, you're ready to link it to a campaign so that the assets can
start serving. This is achieved by creating aCampaignAssetSet.
deflink_asset_set_to_campaign(client:GoogleAdsClient,asset_set_resource_name:str,customer_id:str,campaign_id:str,)->None:"""Creates a CampaignAssetSet.The CampaignAssetSet represents the link between an AssetSet and a Campaign.Args:client: an initialized GoogleAdsClient instance.asset_set_resource_name; the resource name for an asset set.customer_id: a client customer ID.campaign_id: the ID for a campaign of a type that supports dynamicremarketing, such as Display."""googleads_service:GoogleAdsServiceClient=client.get_service("GoogleAdsService")# Creates an operation to add the campaign asset set.operation:CampaignAssetSetOperation=client.get_type("CampaignAssetSetOperation")campaign_asset_set:CampaignAssetSet=operation.createcampaign_asset_set.campaign=googleads_service.campaign_path(customer_id,campaign_id)campaign_asset_set.asset_set=asset_set_resource_namecampaign_asset_set_service:CampaignAssetSetServiceClient=(client.get_service("CampaignAssetSetService"))response:MutateCampaignAssetSetsResponse=(campaign_asset_set_service.mutate_campaign_asset_sets(customer_id=customer_id,operations=[operation]))resource_name:str=response.results[0].resource_nameprint(f"Created a campaign asset set with resource name '{resource_name}'")
deflink_asset_set_to_campaign(client,asset_set_resource_name,customer_id,campaign_id)# Creates a CampaignAssetSet representing the link between an AssetSet and a Campaign.# Creates an operation to add the campaign asset set.operation=client.operation.create_resource.campaign_asset_setdo|cas|cas.campaign=client.path.campaign(customer_id,campaign_id)cas.asset_set=asset_set_resource_nameend# Issues the mutate request.response=client.service.campaign_asset_set.mutate_campaign_asset_sets(customer_id:customer_id,operations:[operation],)resource_name=response.results.first.resource_nameputs"Created a campaign asset set with resource name '#{resource_name}'"end
# Create a CampaignAssetSet representing the link between an AssetSet and a Campaign.my$campaign_asset_set=Google::Ads::GoogleAds::V21::Resources::CampaignAssetSet->new({campaign=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::campaign($customer_id,$campaign_id),assetSet=>$asset_set_resource_name});# Create an operation to add the CampaignAssetSet.my$operation=Google::Ads::GoogleAds::V21::Services::CampaignAssetSetService::CampaignAssetSetOperation->new({create=>$campaign_asset_set});# Issue the mutate request.my$response=$api_client->CampaignAssetSetService()->mutate({customerId=>$customer_id,operations=>[$operation]});# Print some information about the response.my$resource_name=$response->{results}[0]{resourceName};printf"Created a CampaignAssetSet with resource name '%s'.\n",$resource_name;
Once you've set up your campaign with a dynamic remarketing feed, you can
target it with aUserList. This user list should
have been created with the dynamic IDs populated in the tracking pixel.
defattach_user_list(client:GoogleAdsClient,customer_id:str,ad_group_resource_name:str,user_list_id:int,)->None:"""Targets a user list with an ad group.Args:client: An initialized GoogleAds client.customer_id: The Google Ads customer ID.ad_group_resource_name: The resource name of the target ad group.user_list_id: The ID of the user list to target for remarketing."""# Get the AdGroupCriterionService client.ad_group_criterion_service:AdGroupCriterionServiceClient=(client.get_service("AdGroupCriterionService"))# Create an ad group criterion operation and set the ad group criterion# values.ad_group_criterion_operation:AdGroupCriterionOperation=client.get_type("AdGroupCriterionOperation")ad_group_criterion:AdGroupCriterion=ad_group_criterion_operation.createad_group_criterion.ad_group=ad_group_resource_namead_group_criterion.user_list.user_list=client.get_service("UserListService").user_list_path(customer_id,str(user_list_id))# Issue a mutate request to add the ad group criterion.ad_group_criterion_response:MutateAdGroupCriteriaResponse=(ad_group_criterion_service.mutate_ad_group_criteria(customer_id=customer_id,operations=[ad_group_criterion_operation]))print("Created ad group criterion with resource name "f"'{ad_group_criterion_response.results[0].resource_name}'.")
defattach_user_list(client,customer_id,ad_group_resource_name,user_list_id)user_list_resource_name=client.path.user_list(customer_id,user_list_id)# Creates the ad group criterion that targets the user list.ad_group_criterion=client.resource.ad_group_criteriondo|agc|agc.ad_group=ad_group_resource_nameagc.user_list=client.resource.user_list_infodo|ul|ul.user_list=user_list_resource_nameendend# Creates the ad group criterion operation.op=client.operation.create_resource.ad_group_criterion(ad_group_criterion)response=client.service.ad_group_criterion.mutate_ad_group_criteria(customer_id:customer_id,operations:[op])puts"Created ad group criterion:#{response.results.first.resource_name}"end
subattach_user_list{my($api_client,$customer_id,$ad_group_resource_name,$user_list_id)=@_;# Create the ad group criterion that targets the user list.my$ad_group_criterion=Google::Ads::GoogleAds::V21::Resources::AdGroupCriterion->new({adGroup=>$ad_group_resource_name,userList=>Google::Ads::GoogleAds::V21::Common::UserListInfo->new({userList=>Google::Ads::GoogleAds::V21::Utils::ResourceNames::user_list($customer_id,$user_list_id)})});# Create an ad group criterion operation.my$ad_group_criterion_operation=Google::Ads::GoogleAds::V21::Services::AdGroupCriterionService::AdGroupCriterionOperation->new({create=>$ad_group_criterion});# Issue a mutate request to add the ad group criterion.my$ad_group_criteria_response=$api_client->AdGroupCriterionService()->mutate({customerId=>$customer_id,operations=>[$ad_group_criterion_operation]});printf"Created ad group criterion with resource name '%s'.\n",$ad_group_criteria_response->{results}[0]{resourceName};}
Download reports for your dynamic remarketing campaign
There is no reporting available for assets in dynamic remarketing
campaigns in order to maintain feature parity with the legacy feeds-based setup,
which had no FeedItem-level stats. Reporting for dynamic remarketing assets
could be added in a later release.
Specify asset tracking IDs
There are at least two IDs present in each dynamic remarketing asset. Each
dynamic remarketing asset type defines its own unique ID.
For example, in the case ofDynamicEducationAsset, you should specify thedynamic_education_asset.program_idand optionallydynamic_education_asset.location_idin the tracking pixel.
Don't specifyasset.idin the tracking pixel as this has no meaning outside
of the Google Ads API.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-03 UTC."],[[["\u003cp\u003eDynamic remarketing campaigns use the Google Ads API to personalize ads based on user behavior.\u003c/p\u003e\n"],["\u003cp\u003eCreate \u003ccode\u003eAsset\u003c/code\u003e objects to define the dynamic content and package them within an \u003ccode\u003eAssetSet\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eLink the \u003ccode\u003eAssetSet\u003c/code\u003e to your campaigns, enabling them to utilize the assets for dynamic content.\u003c/p\u003e\n"],["\u003cp\u003eUtilize the provided code examples in various programming languages for implementing dynamic remarketing with the Google Ads API.\u003c/p\u003e\n"],["\u003cp\u003eRefer to Google Ads documentation for campaign setup and association with user lists, which are essential for dynamic remarketing functionality.\u003c/p\u003e\n"]]],[],null,[]]