تتضمّن "حملات الأداء الأفضل" بعض الخصائص الفريدة المتعلّقة بمواد العرض.
- هناك حدّ أدنى لعدد مواد العرض المطلوبة من أنواع مختلفة.
- يتم تجميع مواد العرض معًا في مجموعة تُعرف باسم
AssetGroup، وهي فريدة من نوعها في "حملات الأداء الأفضل". - يمكن إنشاء بعض مواد العرض تلقائيًا من خلال تعلُّم الآلة.
إرشادات العلامة التجارية: ربط اسم المؤسسة وشعارها
مع أنّ معظم مواد العرض في "حملة الأداء الأفضل" يتم تنظيمها ضمن مجموعات مواد العرض، يتم التعامل مع مواد العرض الرئيسية التي تمثّل هوية علامتك التجارية، وتحديدًا اسم المؤسسة وشعار المؤسسة، بشكل مختلف في حال تفعيل إرشادات بناء هوية العلامة التجارية في حملتك.
يتم ربط مواد عرض إرشادات العلامة التجارية هذه مباشرةً على مستوى الحملة، وليس على مستوى مجموعة مواد العرض. يتم ذلك باستخدام المورد CampaignAsset. عليك ربط مادة العرض بالحملة، مع تحديد AssetFieldType المناسب:
* `BUSINESS_NAME` for the Business Name asset (which is a Text Asset).
* `LOGO` for the Business Logo asset (which is an Image Asset).
يضمن الربط على مستوى الحملة عرض العلامة التجارية بشكل متّسق في جميع مجموعات مواد العرض ضمن "حملة الأداء الأفضل".
مثال على الرمز
يوضّح مقتطف الرمز التالي كيفية إنشاء مواد العرض المتكرّرة اللازمة في طلب جديد:
Java
/** Creates multiple text assets and returns the list of resource names. */ private List<String> createMultipleTextAssets( GoogleAdsClient googleAdsClient, long customerId, List<String> texts) { List<MutateOperation> mutateOperations = new ArrayList<>(); for (String text : texts) { Asset asset = Asset.newBuilder().setTextAsset(TextAsset.newBuilder().setText(text)).build(); AssetOperation assetOperation = AssetOperation.newBuilder().setCreate(asset).build(); mutateOperations.add(MutateOperation.newBuilder().setAssetOperation(assetOperation).build()); } List<String> assetResourceNames = new ArrayList<>(); // Creates the service client. try (GoogleAdsServiceClient googleAdsServiceClient = googleAdsClient.getLatestVersion().createGoogleAdsServiceClient()) { // Sends the operations in a single Mutate request. MutateGoogleAdsResponse response = googleAdsServiceClient.mutate(Long.toString(customerId), mutateOperations); for (MutateOperationResponse result : response.getMutateOperationResponsesList()) { if (result.hasAssetResult()) { assetResourceNames.add(result.getAssetResult().getResourceName()); } } printResponseDetails(response); } return assetResourceNames; }
#C
/// <summary> /// Creates multiple text assets and returns the list of resource names. /// </summary> /// <param name="client">The Google Ads Client.</param> /// <param name="customerId">The customer's ID.</param> /// <param name="texts">The texts to add.</param> /// <returns>A list of asset resource names.</returns> private List<string> CreateMultipleTextAssets( GoogleAdsClient client, long customerId, string[] texts) { // Get the GoogleAdsService. GoogleAdsServiceClient googleAdsServiceClient = client.GetService(Services.V22.GoogleAdsService); MutateGoogleAdsRequest request = new MutateGoogleAdsRequest() { CustomerId = customerId.ToString() }; foreach (string text in texts) { request.MutateOperations.Add( new MutateOperation() { AssetOperation = new AssetOperation() { Create = new Asset() { TextAsset = new TextAsset() { Text = text } } } } ); } // Send the operations in a single Mutate request. MutateGoogleAdsResponse response = googleAdsServiceClient.Mutate(request); List<string> assetResourceNames = new List<string>(); foreach (MutateOperationResponse operationResponse in response.MutateOperationResponses) { MutateAssetResult assetResult = operationResponse.AssetResult; assetResourceNames.Add(assetResult.ResourceName); } PrintResponseDetails(response); return assetResourceNames; }
PHP
private static function createMultipleTextAssets( GoogleAdsClient $googleAdsClient, int $customerId, array $texts ): array { // Here again, we use the GoogleAdService to create multiple text assets in a single // request. $operations = []; foreach ($texts as $text) { // Creates a mutate operation for a text asset. $operations[] = new MutateOperation([ 'asset_operation' => new AssetOperation([ 'create' => new Asset(['text_asset' => new TextAsset(['text' => $text])]) ]) ]); } // Issues a mutate request to add all assets. $googleAdsService = $googleAdsClient->getGoogleAdsServiceClient(); /** @var MutateGoogleAdsResponse $mutateGoogleAdsResponse */ $mutateGoogleAdsResponse = $googleAdsService->mutate(MutateGoogleAdsRequest::build($customerId, $operations)); $assetResourceNames = []; foreach ($mutateGoogleAdsResponse->getMutateOperationResponses() as $response) { /** @var MutateOperationResponse $response */ $assetResourceNames[] = $response->getAssetResult()->getResourceName(); } self::printResponseDetails($mutateGoogleAdsResponse); return $assetResourceNames; }