> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# حملات Google Performance Max

> أنشئ حملات Performance Max في Google Ads من نصوصك وصورك

> [!WARNING]
>
> **أعدّ تتبّع الإحالات الناجحة أولًا.** يستخدم Performance Max إحالاتك الناجحة لتحديد أماكن عرض الإعلانات ومقدار عروض الأسعار. لا يمنع Ayrshare إنشاء حملة بدونه، لكن قد يحدّ Google من إنفاقها إلى أن يُعدّ تتبّع الإحالات الناجحة في حساب Google Ads الخاص بك. لا يتولى Ayrshare إعداده نيابةً عنك. وعندما لا يحتوي الحساب على أي تتبّع، تتضمن استجابة الإنشاء إدخالًا في `warnings` يوضح ذلك.

أنشئ حملة Performance Max في Google Ads بطلب واحد. ترسل النصوص وعناوين URL للصور، ويمزجها Google في إعلانات عبر Search وYouTube وDisplay وDiscover وGmail وMaps. يُنشئ Ayrshare الميزانية والحملة ومجموعة أصول واحدة وجميع أصولها معًا. وإذا رفض Google أي جزء منها، فلن يُنشأ أي شيء.

يستخدم الطلب البنية المشتركة الموضحة في [الحملات الإعلانية](https://www.ayrshare.com/docs/apis/ads/campaigns.md). تعمل قراءة الحملة وتغييرها والإحصاءات والأخطاء كما في [حملات بحث Google](https://www.ayrshare.com/docs/apis/ads/google/search-campaigns.md). تتناول هذه الصفحة ما يختلف.

<ul>
  <li>تُفعَّل إعلانات Google لكل حساب على حدة. تواصل معنا لتفعيلها.</li>
  <li>تبدأ الحملات الجديدة بالحالة `paused` ما لم ترسل `status: "active"`.</li>
  <li>الميزانية يومية، بعملة حساب الإعلانات، ولا تُشارَك أبدًا مع حملات أخرى.</li>
  <li>يُحوَّل الإنفاق بعملة أخرى إلى الدولار الأمريكي (USD) لأغراض الفوترة بسعر صرف ذلك اليوم من Open Exchange Rates. يُعيد الحساب بعملة لا يمكن تحويلها `code: 101` قبل إنشاء أي شيء.</li>
  <li>الفيديو غير مدعوم. قد يُنشئ Google مقاطع فيديو من صورك.</li>
</ul>

## معاملات الترويسة

**Authorization** `string` *required*

[API Key](https://www.ayrshare.com/docs/apis/overview.md#authorization) of the Primary Profile.

Format: `Authorization: Bearer API_KEY`
**Profile-Key** `string`

[Profile Key](https://www.ayrshare.com/docs/apis/overview.md#profile-key-format) of a User Profile.

Format: `Profile-Key: PROFILE_KEY`

**Idempotency-Key** `string` *required*

قيمة فريدة جديدة، مثل UUID، لكل حملة جديدة. يؤدي تكرار طلب بالمفتاح نفسه إلى إعادة الاستجابة الأولى. عندما يفشل الإنشاء قبل أن يرسل Ayrshare الحملة إلى Google (على سبيل المثال، صورة بحجم غير صحيح)، يُحرَّر المفتاح، فيمكنك تصحيح الطلب وإعادة المحاولة بالمفتاح نفسه.

## معاملات الجسم

**type** `string` *required*

`performanceMax`.

**bidding** `object` *required*

لا يقبل Performance Max إلا الاستراتيجيات التالية. تُعيد أي استراتيجية أخرى `code: 101`.

<ul>
  <li>`maximizeConversions`: الحصول على أكبر عدد من الإحالات الناجحة ضمن الميزانية.</li>
  <li>`targetCpa` مع `targetCpa`: الأمر نفسه، مع استهداف تلك التكلفة لكل إحالة ناجحة.</li>
  <li>`maximizeConversionValue`: الحصول على أعلى قيمة للإحالات الناجحة ضمن الميزانية.</li>
  <li>`targetRoas` مع `targetRoas`: الأمر نفسه، مع استهداف ذلك العائد على الإنفاق الإعلاني، على سبيل المثال `3.5` لنسبة 350%.</li>
</ul>

**euPoliticalAdvertising** `boolean` *required*

يشترط Google هذا الإقرار في كل حملة.

**targeting.locations** `string[]`

معرّفات مواقع Google، على سبيل المثال `2840` للولايات المتحدة. لا ترسل هذا الحقل لاستهداف جميع المواقع.

**platformOptions.google** `object` *required*

**السمات الفرعية**

**finalUrl** `string` *required*

صفحة `http` أو `https` التي تفتحها الإعلانات.

**assets** `object` *required*

نصوصك وصورك. يجب أن تختلف عناصر كل قائمة عن بعضها.

**السمات الفرعية**

**headlines** `string[]` *required*

من 3 إلى 15، لا يتجاوز كل منها 30 حرفًا.

**longHeadlines** `string[]` *required*

من 1 إلى 5، لا يتجاوز كل منها 90 حرفًا.

**descriptions** `string[]` *required*

من 2 إلى 5، لا يتجاوز كل منها 90 حرفًا. يجب ألا يتجاوز واحد منها على الأقل 60 حرفًا.

**businessName** `string` *required*

اسم نشاط تجاري واحد، بحد أقصى 25 حرفًا.

**marketingImages** `string[]` *required*

من 1 إلى 20 عنوان URL لصور أفقية: بنسبة 1.91:1، وبحجم 600×314 على الأقل.

**squareMarketingImages** `string[]` *required*

من 1 إلى 20 عنوان URL لصور مربعة: بنسبة 1:1، وبحجم 300×300 على الأقل.

**logos** `string[]` *required*

من 1 إلى 5 عناوين URL لشعارات مربعة: بنسبة 1:1، وبحجم 128×128 على الأقل.

**landscapeLogos** `string[]`

حتى 4 عناوين URL لشعارات عريضة: بنسبة 4:1، وبحجم 512×128 على الأقل. يقبل Google خمسة شعارات وشعارات عريضة معًا كحد أقصى.

### الصور

يُنزّل Ayrshare كل صورة من عنوان URL الخاص بها ويتحقق منها قبل إرسال أي شيء إلى Google:

<ul>
  <li>بتنسيق GIF أو JPG أو PNG، بحد أقصى 5120 كيلوبايت لكل صورة.</li>
  <li>بالحجم الأدنى المذكور أعلاه على الأقل، وبنسبة العرض إلى الارتفاع الخاصة بحقلها (بفارق لا يتجاوز 1%).</li>
  <li>بحد أقصى 45 ميغابايت لجميع الصور معًا.</li>
  <li>يجب أن يكون عنوان URL عامًا. تُرفض العناوين الخاصة.</li>
</ul>

تُعيد الصورة التي لا تجتاز التحقق `code: 101` مع ذكر اسمها، على سبيل المثال `platformOptions.google.assets.logos[0]: the image is 100x100; use at least 128x128.`

```bash cURL theme={"system"}
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11" \
-X POST https://api.ayrshare.com/api/ads/google/campaigns \
-d '{
  "accountId": "123-456-7890",
  "name": "Fall sale PMax",
  "type": "performanceMax",
  "budget": { "amount": 40, "type": "daily" },
  "bidding": { "strategy": "maximizeConversions" },
  "targeting": { "locations": ["2840"] },
  "euPoliticalAdvertising": false,
  "platformOptions": {
    "google": {
      "finalUrl": "https://example.com/fall-sale",
      "assets": {
        "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
        "longHeadlines": ["Every running shoe 30% off this week only"],
        "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
        "businessName": "Acme Shoes",
        "marketingImages": ["https://example.com/images/fall-1200x628.png"],
        "squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
        "logos": ["https://example.com/images/logo-512.png"]
      }
    }
  }
}'
```

```javascript JavaScript theme={"system"}
const API_KEY = "API_KEY";

fetch("https://api.ayrshare.com/api/ads/google/campaigns", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11"
  },
  body: JSON.stringify({
    "accountId": "123-456-7890",
    "name": "Fall sale PMax",
    "type": "performanceMax",
    "budget": { "amount": 40, "type": "daily" },
    "bidding": { "strategy": "maximizeConversions" },
    "targeting": { "locations": ["2840"] },
    "euPoliticalAdvertising": false,
    "platformOptions": {
      "google": {
        "finalUrl": "https://example.com/fall-sale",
        "assets": {
          "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
          "longHeadlines": ["Every running shoe 30% off this week only"],
          "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
          "businessName": "Acme Shoes",
          "marketingImages": ["https://example.com/images/fall-1200x628.png"],
          "squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
          "logos": ["https://example.com/images/logo-512.png"]
        }
      }
    }
  })
})
  .then((res) => res.json())
  .then((json) => console.log(json))
  .catch(console.error);
```

```python Python theme={"system"}
import requests

headers = {
    "Authorization": "Bearer API_KEY",
    "Idempotency-Key": "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11",
}

payload = {
  "accountId": "123-456-7890",
  "name": "Fall sale PMax",
  "type": "performanceMax",
  "budget": { "amount": 40, "type": "daily" },
  "bidding": { "strategy": "maximizeConversions" },
  "targeting": { "locations": ["2840"] },
  "euPoliticalAdvertising": False,
  "platformOptions": {
    "google": {
      "finalUrl": "https://example.com/fall-sale",
      "assets": {
        "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
        "longHeadlines": ["Every running shoe 30% off this week only"],
        "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
        "businessName": "Acme Shoes",
        "marketingImages": ["https://example.com/images/fall-1200x628.png"],
        "squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
        "logos": ["https://example.com/images/logo-512.png"]
      }
    }
  }
}

r = requests.post("https://api.ayrshare.com/api/ads/google/campaigns", headers=headers, json=payload)

print(r.json())
```

```php PHP theme={"system"}
<?php
$payload = <<<'JSON'
{
  "accountId": "123-456-7890",
  "name": "Fall sale PMax",
  "type": "performanceMax",
  "budget": { "amount": 40, "type": "daily" },
  "bidding": { "strategy": "maximizeConversions" },
  "targeting": { "locations": ["2840"] },
  "euPoliticalAdvertising": false,
  "platformOptions": {
    "google": {
      "finalUrl": "https://example.com/fall-sale",
      "assets": {
        "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
        "longHeadlines": ["Every running shoe 30% off this week only"],
        "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
        "businessName": "Acme Shoes",
        "marketingImages": ["https://example.com/images/fall-1200x628.png"],
        "squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
        "logos": ["https://example.com/images/logo-512.png"]
      }
    }
  }
}
JSON;

$curl = curl_init();

curl_setopt_array($curl, [
    CURLOPT_URL => "https://api.ayrshare.com/api/ads/google/campaigns",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer API_KEY",
        "Content-Type: application/json",
        "Idempotency-Key: 0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11"
    ],
    CURLOPT_POSTFIELDS => $payload
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
    echo "cURL Error: " . $err;
} else {
    echo $response;
}
?>
```

```csharp C# theme={"system"}
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", "Bearer API_KEY");
        client.DefaultRequestHeaders.Add("Idempotency-Key", "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11");

        var payload = """
            {
              "accountId": "123-456-7890",
              "name": "Fall sale PMax",
              "type": "performanceMax",
              "budget": { "amount": 40, "type": "daily" },
              "bidding": { "strategy": "maximizeConversions" },
              "targeting": { "locations": ["2840"] },
              "euPoliticalAdvertising": false,
              "platformOptions": {
                "google": {
                  "finalUrl": "https://example.com/fall-sale",
                  "assets": {
                    "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
                    "longHeadlines": ["Every running shoe 30% off this week only"],
                    "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
                    "businessName": "Acme Shoes",
                    "marketingImages": ["https://example.com/images/fall-1200x628.png"],
                    "squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
                    "logos": ["https://example.com/images/logo-512.png"]
                  }
                }
              }
            }
            """;

        var response = await client.PostAsync(
            "https://api.ayrshare.com/api/ads/google/campaigns",
            new StringContent(payload, Encoding.UTF8, "application/json"));
        var content = await response.Content.ReadAsStringAsync();

        Console.WriteLine(content);
    }
}
```

```go Go theme={"system"}
package main

import (
    "fmt"
    "io"
    "net/http"
    "strings"
)

func main() {
    payload := `{
  "accountId": "123-456-7890",
  "name": "Fall sale PMax",
  "type": "performanceMax",
  "budget": { "amount": 40, "type": "daily" },
  "bidding": { "strategy": "maximizeConversions" },
  "targeting": { "locations": ["2840"] },
  "euPoliticalAdvertising": false,
  "platformOptions": {
    "google": {
      "finalUrl": "https://example.com/fall-sale",
      "assets": {
        "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
        "longHeadlines": ["Every running shoe 30% off this week only"],
        "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
        "businessName": "Acme Shoes",
        "marketingImages": ["https://example.com/images/fall-1200x628.png"],
        "squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
        "logos": ["https://example.com/images/logo-512.png"]
      }
    }
  }
}`

    req, _ := http.NewRequest("POST", "https://api.ayrshare.com/api/ads/google/campaigns", strings.NewReader(payload))
    req.Header.Add("Authorization", "Bearer API_KEY")
    req.Header.Add("Content-Type", "application/json")
    req.Header.Add("Idempotency-Key", "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11")

    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

```java Java theme={"system"}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class CreateCampaign {
    public static void main(String[] args) throws Exception {
        String payload = """
            {
              "accountId": "123-456-7890",
              "name": "Fall sale PMax",
              "type": "performanceMax",
              "budget": { "amount": 40, "type": "daily" },
              "bidding": { "strategy": "maximizeConversions" },
              "targeting": { "locations": ["2840"] },
              "euPoliticalAdvertising": false,
              "platformOptions": {
                "google": {
                  "finalUrl": "https://example.com/fall-sale",
                  "assets": {
                    "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
                    "longHeadlines": ["Every running shoe 30% off this week only"],
                    "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
                    "businessName": "Acme Shoes",
                    "marketingImages": ["https://example.com/images/fall-1200x628.png"],
                    "squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
                    "logos": ["https://example.com/images/logo-512.png"]
                  }
                }
              }
            }
            """;

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.ayrshare.com/api/ads/google/campaigns"))
            .header("Authorization", "Bearer API_KEY")
            .header("Content-Type", "application/json")
            .header("Idempotency-Key", "0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11")
            .POST(HttpRequest.BodyPublishers.ofString(payload))
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}
```

```ruby Ruby theme={"system"}
require 'net/http'
require 'uri'

uri = URI.parse('https://api.ayrshare.com/api/ads/google/campaigns')

request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer API_KEY'
request['Content-Type'] = 'application/json'
request['Idempotency-Key'] = '0b7a6f1c-2d4e-4c55-9a3e-2f8d1b7c9e11'
request.body = <<~JSON
  {
    "accountId": "123-456-7890",
    "name": "Fall sale PMax",
    "type": "performanceMax",
    "budget": { "amount": 40, "type": "daily" },
    "bidding": { "strategy": "maximizeConversions" },
    "targeting": { "locations": ["2840"] },
    "euPoliticalAdvertising": false,
    "platformOptions": {
      "google": {
        "finalUrl": "https://example.com/fall-sale",
        "assets": {
          "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
          "longHeadlines": ["Every running shoe 30% off this week only"],
          "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
          "businessName": "Acme Shoes",
          "marketingImages": ["https://example.com/images/fall-1200x628.png"],
          "squareMarketingImages": ["https://example.com/images/fall-1200x1200.png"],
          "logos": ["https://example.com/images/logo-512.png"]
        }
      }
    }
  }
JSON

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

puts response.body
```

```json 200: Campaign Created theme={"system"}
{
  "status": "success",
  "platform": "google",
  "campaignId": "21534567891",
  "assetGroupId": "6512345678",
  "campaignStatus": "paused"
}
```

```json 200: Created, No Conversion Tracking theme={"system"}
{
  "status": "success",
  "platform": "google",
  "campaignId": "21534567891",
  "assetGroupId": "6512345678",
  "campaignStatus": "paused",
  "warnings": [
    "This Google Ads account has no conversion tracking. Performance Max optimizes for conversions, so Google may limit the campaign's spend until you set up conversion tracking in Google Ads."
  ]
}
```

```json 400: Image Too Small theme={"system"}
{
  "action": "request",
  "status": "error",
  "code": 101,
  "message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
  "details": "platformOptions.google.assets.logos[0]: the image is 100x100; use at least 128x128."
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.