> ## 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 सर्च अभियान

> एक ही अनुरोध में बजट, कीवर्ड, विज्ञापन टेक्स्ट और स्थान टार्गेटिंग के साथ Google Ads सर्च अभियान बनाएँ

एक ही अनुरोध में Google Ads सर्च अभियान बनाएँ। Ayrshare बजट, अभियान, एक ऐड ग्रुप, आपके कीवर्ड, एक रिस्पॉन्सिव सर्च विज्ञापन, और लोकेशन टार्गेटिंग को एक साथ बनाता है। यदि Google किसी भी हिस्से को अस्वीकार करता है, तो कुछ भी नहीं बनाया जाता।

अनुरोध साझा [विज्ञापन अभियान](https://www.ayrshare.com/docs/apis/ads/campaigns.md) स्वरूप का उपयोग करता है। यह पेज उन बातों को कवर करता है जो Google के लिए विशिष्ट हैं।

<ul>
  <li>Google विज्ञापन प्रति खाता चालू किए जाते हैं। इन्हें सक्षम करने के लिए हमसे संपर्क करें।</li>
  <li>पहले "Social Accounts" पेज से Google Ads लिंक करें। `accountId` 10 अंकों की Google Ads customer id है, हाइफ़न के साथ या बिना (`123-456-7890`)।</li>
  <li>आप जिस Google यूज़र को लिंक करते हैं, उसके पास विज्ञापन खाते का सीधा एक्सेस होना चाहिए। जिन खातों तक आप केवल किसी मैनेजर खाते के माध्यम से पहुँचते हैं, वे सूचीबद्ध नहीं होते और अभी उनका उपयोग नहीं किया जा सकता: उस यूज़र को सीधे विज्ञापन खाते में जोड़ें। मैनेजर खाते भी सूचीबद्ध नहीं होते: उनमें अभियान नहीं हो सकते।</li>
  <li>नए अभियान `paused` स्थिति में शुरू होते हैं, जब तक आप `status: "active"` नहीं भेजते।</li>
  <li>बजट प्रति दिन होता है, विज्ञापन खाते की मुद्रा में। `budget.currency` न भेजें: यह `code: 101` लौटाता है।</li>
  <li>किसी अन्य मुद्रा में हुआ खर्च बिलिंग के लिए Open Exchange Rates की उस दिन की विनिमय दर पर USD में बदला जाता है। ऐसी मुद्रा वाला खाता जिसे बदला नहीं जा सकता, कुछ भी बनाए जाने से पहले `code: 101` लौटाता है।</li>
  <li>विज्ञापन केवल Google Search पर दिखते हैं, सर्च पार्टनर्स या Display Network पर नहीं।</li>
</ul>

> [!NOTE]
>
> **कन्वर्ज़न ट्रैकिंग।** `maximizeConversions` केवल तभी काम करता है जब आपके Google Ads खाते में कन्वर्ज़न ट्रैकिंग सेट अप हो। Ayrshare इसे आपके लिए सेट अप नहीं करता। इसके बिना, `maximizeClicks` या `manualCpc` का उपयोग करें।

## हेडर पैरामीटर

**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। किसी अनुरोध को उसी key के साथ दोहराने पर पहला रिस्पॉन्स लौटता है और कुछ भी नया नहीं बनता। जब कोई create, Ayrshare द्वारा अभियान को Google पर भेजे जाने से पहले विफल होता है, तो key मुक्त हो जाती है, इसलिए आप अनुरोध ठीक करके उसी key के साथ पुनः प्रयास कर सकते हैं। इसमें वह मान शामिल है जिसे Ayrshare अस्वीकार करता है (जैसे कोई असमर्थित बिडिंग रणनीति), ऐसी मुद्रा वाला खाता जिसे USD में बदला नहीं जा सकता, और Ayrshare द्वारा पहले की जाने वाली खाता जाँच की कोई भी विफलता, जिसमें Google द्वारा उसे अस्वीकार करना भी शामिल है। जो create अभियान को Google पर भेजे जाने के बाद विफल होता है, वह अपना उत्तर बनाए रखता है: उसे नई key के साथ पुनः प्रयास करें।

## बॉडी पैरामीटर

साझा फ़ील्ड वैसे ही काम करते हैं जैसा [विज्ञापन अभियान](https://www.ayrshare.com/docs/apis/ads/campaigns.md) पर बताया गया है। Google पर:

**type** `string` *required*

`search`।

**bidding.strategy** `string` *required*

`maximizeClicks`, `manualCpc`, या `maximizeConversions`। कोई अन्य मान `code: 101` लौटाता है।

**euPoliticalAdvertising** `boolean` *required*

Google हर अभियान पर इस घोषणा की माँग करता है। जब तक किसी खाते का कोई भी अभियान अघोषित है, Google उस खाते के अभियानों में हर बदलाव को अस्वीकार कर देता है।

**schedule** `object`

Google विज्ञापन खाते के टाइम ज़ोन में पूरे दिनों का शेड्यूल बनाता है। `start` अपने दिन के 00:00:00 पर शुरू होता है और `end` अपने दिन के 23:59:59 पर रुकता है; आपके द्वारा भेजा गया समय केवल दिन चुनता है। `start` आज का दिन हो सकता है, लेकिन उससे पहले का कोई दिन नहीं। एक दिन के अभियान के लिए, `start` और `end` दोनों में एक ही तिथि भेजें। `start` से पहले के किसी दिन का `end` `code: 101` लौटाता है।

**targeting** `object`

Google सर्च विज्ञापनों को आपके विज्ञापन टेक्स्ट की भाषा के आधार पर लोगों से मिलाता है, इसलिए कोई भाषा सेटिंग नहीं है। `targeting.languages` भेजने पर `code: 101` लौटता है।

**गुण**

**locations** `string[]`

Google location ids, उदाहरण के लिए संयुक्त राज्य अमेरिका के लिए `2840`। ids को Google की [geo targets सूची](https://developers.google.com/google-ads/api/data/geotargets) में खोजें। हर लोकेशन को टार्गेट करने के लिए इसे छोड़ दें।

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

**गुण**

**finalUrl** `string` *required*

वह `http` या `https` पेज जिसे विज्ञापन खोलता है।

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

3 से 15 हेडलाइन, प्रत्येक अधिकतम 30 अक्षर।

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

2 से 4 विवरण, प्रत्येक अधिकतम 90 अक्षर।

**path1** `string`

डोमेन के बाद दिखाए जाने वाले डिस्प्ले पाथ का पहला भाग, अधिकतम 15 अक्षर।

**path2** `string`

डिस्प्ले पाथ का दूसरा भाग, अधिकतम 15 अक्षर। इसके लिए `path1` आवश्यक है।

**keywords** `object[]` *required*

कम से कम एक कीवर्ड: `{ "text": string, "matchType": "exact" | "phrase" | "broad" }`। `text` अधिकतम 80 अक्षर और 10 शब्दों का होता है।

**maxCpc** `number`

प्रति क्लिक भुगतान की जाने वाली अधिकतम राशि, खाते की मुद्रा में। `manualCpc` के साथ आवश्यक। `maximizeClicks` के साथ यह प्रत्येक बिड की सीमा तय करता है। `maximizeConversions` के साथ स्वीकार नहीं किया जाता।

```bash cURL theme={"system"}
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10" \
-X POST https://api.ayrshare.com/api/ads/google/campaigns \
-d '{
  "accountId": "123-456-7890",
  "name": "Fall sale",
  "type": "search",
  "budget": { "amount": 25, "type": "daily" },
  "bidding": { "strategy": "maximizeClicks" },
  "targeting": { "locations": ["2840"] },
  "euPoliticalAdvertising": false,
  "platformOptions": {
    "google": {
      "finalUrl": "https://example.com/fall-sale",
      "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
      "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
      "path1": "shoes",
      "keywords": [
        { "text": "running shoes", "matchType": "phrase" },
        { "text": "trail running shoes", "matchType": "exact" }
      ]
    }
  }
}'
```

```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": "6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10"
  },
  body: JSON.stringify({
    "accountId": "123-456-7890",
    "name": "Fall sale",
    "type": "search",
    "budget": { "amount": 25, "type": "daily" },
    "bidding": { "strategy": "maximizeClicks" },
    "targeting": { "locations": ["2840"] },
    "euPoliticalAdvertising": false,
    "platformOptions": {
      "google": {
        "finalUrl": "https://example.com/fall-sale",
        "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
        "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
        "path1": "shoes",
        "keywords": [
          { "text": "running shoes", "matchType": "phrase" },
          { "text": "trail running shoes", "matchType": "exact" }
        ]
      }
    }
  })
})
  .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": "6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10",
}

payload = {
  "accountId": "123-456-7890",
  "name": "Fall sale",
  "type": "search",
  "budget": { "amount": 25, "type": "daily" },
  "bidding": { "strategy": "maximizeClicks" },
  "targeting": { "locations": ["2840"] },
  "euPoliticalAdvertising": False,
  "platformOptions": {
    "google": {
      "finalUrl": "https://example.com/fall-sale",
      "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
      "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
      "path1": "shoes",
      "keywords": [
        { "text": "running shoes", "matchType": "phrase" },
        { "text": "trail running shoes", "matchType": "exact" }
      ]
    }
  }
}

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",
  "type": "search",
  "budget": { "amount": 25, "type": "daily" },
  "bidding": { "strategy": "maximizeClicks" },
  "targeting": { "locations": ["2840"] },
  "euPoliticalAdvertising": false,
  "platformOptions": {
    "google": {
      "finalUrl": "https://example.com/fall-sale",
      "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
      "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
      "path1": "shoes",
      "keywords": [
        { "text": "running shoes", "matchType": "phrase" },
        { "text": "trail running shoes", "matchType": "exact" }
      ]
    }
  }
}
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: 6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10"
    ],
    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", "6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10");

        var payload = """
            {
              "accountId": "123-456-7890",
              "name": "Fall sale",
              "type": "search",
              "budget": { "amount": 25, "type": "daily" },
              "bidding": { "strategy": "maximizeClicks" },
              "targeting": { "locations": ["2840"] },
              "euPoliticalAdvertising": false,
              "platformOptions": {
                "google": {
                  "finalUrl": "https://example.com/fall-sale",
                  "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
                  "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
                  "path1": "shoes",
                  "keywords": [
                    { "text": "running shoes", "matchType": "phrase" },
                    { "text": "trail running shoes", "matchType": "exact" }
                  ]
                }
              }
            }
            """;

        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",
  "type": "search",
  "budget": { "amount": 25, "type": "daily" },
  "bidding": { "strategy": "maximizeClicks" },
  "targeting": { "locations": ["2840"] },
  "euPoliticalAdvertising": false,
  "platformOptions": {
    "google": {
      "finalUrl": "https://example.com/fall-sale",
      "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
      "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
      "path1": "shoes",
      "keywords": [
        { "text": "running shoes", "matchType": "phrase" },
        { "text": "trail running shoes", "matchType": "exact" }
      ]
    }
  }
}`

    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", "6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10")

    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",
              "type": "search",
              "budget": { "amount": 25, "type": "daily" },
              "bidding": { "strategy": "maximizeClicks" },
              "targeting": { "locations": ["2840"] },
              "euPoliticalAdvertising": false,
              "platformOptions": {
                "google": {
                  "finalUrl": "https://example.com/fall-sale",
                  "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
                  "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
                  "path1": "shoes",
                  "keywords": [
                    { "text": "running shoes", "matchType": "phrase" },
                    { "text": "trail running shoes", "matchType": "exact" }
                  ]
                }
              }
            }
            """;

        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", "6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10")
            .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'] = '6f1c2d4e-0b7a-4c55-9a3e-2f8d1b7c9e10'
request.body = <<~JSON
  {
    "accountId": "123-456-7890",
    "name": "Fall sale",
    "type": "search",
    "budget": { "amount": 25, "type": "daily" },
    "bidding": { "strategy": "maximizeClicks" },
    "targeting": { "locations": ["2840"] },
    "euPoliticalAdvertising": false,
    "platformOptions": {
      "google": {
        "finalUrl": "https://example.com/fall-sale",
        "headlines": ["Fall sale", "Shoes 30% off", "Free returns"],
        "descriptions": ["Every shoe 30% off this week.", "Free returns on every order."],
        "path1": "shoes",
        "keywords": [
          { "text": "running shoes", "matchType": "phrase" },
          { "text": "trail running shoes", "matchType": "exact" }
        ]
      }
    }
  }
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": "21534567890",
  "adGroupId": "16812345678",
  "adId": "71234567890",
  "campaignStatus": "paused"
}
```

```json 400: Too Few Headlines 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.headlines: Supply at least 3 headlines."
}
```

## त्रुटियाँ

| कोड | कब |
| - | - |
| `101` | कोई फ़ील्ड अनुपस्थित या अमान्य है। `details` उसका नाम बताता है। |
| `205` | Google ने अनुरोध अस्वीकार कर दिया: उदाहरण के लिए, खाते में इस नाम का अभियान पहले से मौजूद है, या विज्ञापन टेक्स्ट Google की विज्ञापन नीतियों का उल्लंघन करता है। `details` बताता है कि क्या बदलना है। |
| `400` | आपके द्वारा लिंक किया गया Google यूज़र इस विज्ञापन खाते तक नहीं पहुँच सकता, Google Ads एक्सेस रद्द कर दिया गया था, अभियान आपका नहीं है, या कोई बदलाव ऐसे अभियान को टार्गेट करता है जिसे Google Ads में हटा दिया गया है। |
| `370` | Google अनुरोध पूरा नहीं कर सका, या Google ने अभी तक Ayrshare के एक्सेस को स्वीकृति नहीं दी है। यदि Google की request id उपलब्ध हो, तो `details` में वह शामिल होती है। जो create `370` इसलिए लौटाता है क्योंकि Google का जवाब खो गया था, उसने फिर भी अभियान बना दिया हो सकता है। Google एक खाते में समान नाम वाले दूसरे अभियान को अस्वीकार करता है, इसलिए उसी `name` के साथ पुनः प्रयास करने पर डुप्लिकेट बनने के बजाय `205` लौटता है। |


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