Pour discuter de nos produits et nous faire part de vos commentaires, rejoignez le canal Discord officiel Google Ads sur le serveur de la communauté Google Advertising and Measurement.
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Pour diffuser des annonces pour votre campagne Shopping, vous devez créer un AdGroup.
Les campagnes Shopping standards sont compatibles avec le type de groupe d'annonces SHOPPING_PRODUCT_ADS. Il s'agit du type de groupe d'annonces par défaut pour les campagnes Shopping, qui diffuse des annonces standards pour un produit. Vous pouvez le définir en fournissant le champ type du groupe d'annonces.
Les campagnes Shopping standards peuvent contenir plusieurs groupes d'annonces, chacun comportant au moins une annonce.
Cet exemple de code montre comment créer un groupe d'annonces pour une campagne Shopping standard. L'exemple définit également une enchère au CPC correspondant à la stratégie d'enchères de la campagne, qui est définie sur ManualCpc.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/06 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/06 (UTC)."],[[["\u003cp\u003eTo display ads for Shopping campaigns, you need to create an \u003ccode\u003eAdGroup\u003c/code\u003e with the type set to \u003ccode\u003eSHOPPING_PRODUCT_ADS\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eStandard Shopping campaigns can have multiple ad groups, each containing at least one ad.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code examples demonstrate how to create an ad group for a Standard Shopping campaign, including setting a CPC bid.\u003c/p\u003e\n"]]],[],null,["# Creating a Shopping Ad Group\n\nTo serve ads for your Shopping campaign, you must create an\n[`AdGroup`](/google-ads/api/reference/rpc/v21/AdGroup).\n\nStandard Shopping campaigns support the\n[`SHOPPING_PRODUCT_ADS`](/google-ads/api/reference/rpc/v21/AdGroupTypeEnum.AdGroupType#shopping_product_ads)\nad group type. This is the default ad group type for Shopping campaigns, serving\nstandard product ads. It can be set by providing the ad group\n[`type`](/google-ads/api/reference/rpc/v21/AdGroup#type) field.\n\nStandard Shopping campaigns can contain multiple ad groups, each containing at\nleast one ad.\n\nThis code example demonstrates how to create an ad group for a standard Shopping\ncampaign. The example also sets a CPC bid to match the campaign's bid strategy,\nwhich is set to [`ManualCpc`](/google-ads/api/reference/rpc/v21/ManualCpc).\n\n\n### Java\n\n```java\nprivate String addShoppingProductAdGroup(\n GoogleAdsClient googleAdsClient, long customerId, String campaignResourceName) {\n // Creates an ad group.\n AdGroup adGroup =\n AdGroup.newBuilder()\n .setName(\"Earth to Mars Cruises #\" + getPrintableDateTime())\n .setCampaign(campaignResourceName)\n // Sets the ad group type to SHOPPING_PRODUCT_ADS. This is the only value possible for\n // ad groups that contain shopping product ads.\n .setType(AdGroupType.SHOPPING_PRODUCT_ADS)\n .setCpcBidMicros(1_000_000L)\n .setStatus(AdGroupStatus.ENABLED)\n .build();\n\n // Creates an ad group operation.\n AdGroupOperation operation = AdGroupOperation.newBuilder().setCreate(adGroup).build();\n\n // Issues a mutate request to add an ad group.\n try (AdGroupServiceClient adGroupServiceClient =\n googleAdsClient.getLatestVersion().createAdGroupServiceClient()) {\n MutateAdGroupResult mutateAdGroupResult =\n adGroupServiceClient\n .mutateAdGroups(Long.toString(customerId), Collections.singletonList(operation))\n .getResults(0);\n System.out.printf(\n \"Added a product shopping ad group with resource name: '%s'%n\",\n mutateAdGroupResult.getResourceName());\n return mutateAdGroupResult.getResourceName();\n }\n}\nhttps://github.com/googleads/google-ads-java/blob/3c3c1041c2a0ab81553e3b2a79876256649397ed/google-ads-examples/src/main/java/com/google/ads/googleads/examples/shoppingads/AddShoppingProductAd.java#L282-L312\n \n```\n\n### C#\n\n```c#\nprivate string AddProductShoppingAdGroup(GoogleAdsClient client, long customerId,\n string campaignResourceName)\n{\n // Get the AdGroupService.\n AdGroupServiceClient adGroupService = client.GetService(Services.V21.AdGroupService);\n\n // Creates an ad group.\n AdGroup adGroup = new AdGroup()\n {\n Name = \"Earth to Mars Cruises #\" + ExampleUtilities.GetRandomString(),\n Campaign = campaignResourceName,\n // Sets the ad group type to SHOPPING_PRODUCT_ADS. This is the only value possible\n // for ad groups that contain shopping product ads.\n Type = AdGroupType.ShoppingProductAds,\n CpcBidMicros = 1_000_000L,\n Status = AdGroupStatus.Enabled\n };\n\n // Creates an ad group operation.\n AdGroupOperation operation = new AdGroupOperation()\n {\n Create = adGroup\n };\n\n // Issues a mutate request to add an ad group.\n MutateAdGroupResult mutateAdGroupResult =\n adGroupService\n .MutateAdGroups(customerId.ToString(), new AdGroupOperation[] { operation })\n .Results[0];\n Console.WriteLine(\"Added a product shopping ad group with resource name: '{0}'.\",\n mutateAdGroupResult.ResourceName);\n return mutateAdGroupResult.ResourceName;\n}https://github.com/googleads/google-ads-dotnet/blob/ada966e1983b655e82172b6c3e7d9b091b522377/Google.Ads.GoogleAds/examples/ShoppingAds/AddShoppingProductAd.cs#L278-L310\n \n```\n\n### PHP\n\n```php\nprivate static function addShoppingProductAdGroup(\n GoogleAdsClient $googleAdsClient,\n int $customerId,\n string $campaignResourceName\n) {\n // Creates an ad group.\n $adGroup = new AdGroup([\n 'name' =\u003e 'Earth to Mars Cruise #' . Helper::getPrintableDatetime(),\n // Sets the campaign.\n 'campaign' =\u003e $campaignResourceName,\n // Sets the ad group type to SHOPPING_PRODUCT_ADS. This is the only value possible for\n // ad groups that contain shopping product ads.\n 'type' =\u003e AdGroupType::SHOPPING_PRODUCT_ADS,\n 'cpc_bid_micros' =\u003e 10000000,\n 'status' =\u003e AdGroupStatus::ENABLED\n ]);\n\n // Creates an ad group operation.\n $adGroupOperation = new AdGroupOperation();\n $adGroupOperation-\u003esetCreate($adGroup);\n\n // Issues a mutate request to add an ad group.\n $adGroupServiceClient = $googleAdsClient-\u003egetAdGroupServiceClient();\n $response = $adGroupServiceClient-\u003emutateAdGroups(\n MutateAdGroupsRequest::build($customerId, [$adGroupOperation])\n );\n\n /** @var AdGroup $addedAdGroup */\n $addedAdGroup = $response-\u003egetResults()[0];\n printf(\n \"Added a shopping product ad group with resource name '%s'.%s\",\n $addedAdGroup-\u003egetResourceName(),\n PHP_EOL\n );\n\n return $addedAdGroup-\u003egetResourceName();\n} \nhttps://github.com/googleads/google-ads-php/blob/be0249c30c27b4760387bec6682b82c9f4167761/examples/ShoppingAds/AddShoppingProductAd.php#L292-L328\n\n \n```\n\n### Python\n\n```python\ndef add_shopping_product_ad_group(\n client: GoogleAdsClient,\n customer_id: str,\n campaign_resource_name: str,\n) -\u003e str:\n \"\"\"Creates a new shopping product ad group in the specified campaign.\"\"\"\n ad_group_service: AdGroupServiceClient = client.get_service(\n \"AdGroupService\"\n )\n\n # Create ad group.\n ad_group_operation: AdGroupOperation = client.get_type(\"AdGroupOperation\")\n ad_group: AdGroup = ad_group_operation.create\n ad_group.name = f\"Earth to Mars cruise {uuid.uuid4()}\"\n ad_group.status = client.enums.AdGroupStatusEnum.ENABLED\n ad_group.campaign = campaign_resource_name\n # Sets the ad group type to SHOPPING_PRODUCT_ADS. This is the only value\n # possible for ad groups that contain shopping product ads.\n ad_group.type_ = client.enums.AdGroupTypeEnum.SHOPPING_PRODUCT_ADS\n ad_group.cpc_bid_micros = 10000000\n\n # Add the ad group.\n ad_group_response = ad_group_service.mutate_ad_groups(\n customer_id=customer_id, operations=[ad_group_operation]\n )\n\n ad_group_resource_name: str = ad_group_response.results[0].resource_name\n\n print(\n \"Added a product shopping ad group with resource name \"\n f\"'{ad_group_resource_name}'.\"\n )\n\n return ad_group_resource_name \nhttps://github.com/googleads/google-ads-python/blob/d0595698b8a7de6cc00684b467462601037c9db9/examples/shopping_ads/add_shopping_product_ad.py#L180-L213\n \n```\n\n### Ruby\n\n```ruby\ndef add_shopping_product_ad_group(client, customer_id, campaign_name)\n operation = client.operation.create_resource.ad_group do |ad_group|\n ad_group.name = \"Earth to Mars cruise ##{(Time.new.to_f * 1000).to_i}\"\n ad_group.status = :ENABLED\n ad_group.campaign = campaign_name\n ad_group.type = :SHOPPING_PRODUCT_ADS\n ad_group.cpc_bid_micros = 10_000_000\n end\n\n service = client.service.ad_group\n response = service.mutate_ad_groups(\n customer_id: customer_id,\n operations: [operation],\n )\n\n ad_group_name = response.results.first.resource_name\n\n puts \"Added a product shopping ad group with resource name #{ad_group_name}.\"\n\n ad_group_name\nend \nhttps://github.com/googleads/google-ads-ruby/blob/2752563c7ffd15a4d2238116869f64aea3011cc3/examples/shopping_ads/add_shopping_product_ad.rb#L125-L145\n\n \n```\n\n### Perl\n\n```perl\nsub add_shopping_product_ad_group {\n my ($api_client, $customer_id, $campaign_resource_name) = @_;\n\n # Create an ad group.\n my $ad_group = Google::Ads::GoogleAds::V21::Resources::AdGroup-\u003enew({\n name =\u003e \"Earth to Mars Cruises #\" . uniqid(),\n campaign =\u003e $campaign_resource_name,\n # Set the ad group type to SHOPPING_PRODUCT_ADS. This is the only value\n # possible for ad groups that contain shopping product ads.\n type =\u003e SHOPPING_PRODUCT_ADS,\n cpcBidMicros =\u003e 1000000,\n status =\u003e Google::Ads::GoogleAds::V21::Enums::AdGroupStatusEnum::ENABLED\n });\n\n # Create an ad group operation.\n my $ad_group_operation =\n Google::Ads::GoogleAds::V21::Services::AdGroupService::AdGroupOperation-\u003e\n new({create =\u003e $ad_group});\n\n # Add the ad group.\n my $ad_group_resource_name = $api_client-\u003eAdGroupService()-\u003emutate({\n customerId =\u003e $customer_id,\n operations =\u003e [$ad_group_operation]})-\u003e{results}[0]{resourceName};\n\n printf \"Added a product shopping ad group with resource name: '%s'.\\n\",\n $ad_group_resource_name;\n\n return $ad_group_resource_name;\n}https://github.com/googleads/google-ads-perl/blob/9abffd69cd856633dfdcee5c636fe9cd0eb4b5ed/examples/shopping_ads/add_shopping_product_ad.pl#L203-L231\n \n```\n\n\u003cbr /\u003e"]]