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"]
}
}
}
}'
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);
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
$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;
}
?>
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);
}
}
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))
}
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());
}
}
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
{
"status": "success",
"platform": "google",
"campaignId": "21534567891",
"assetGroupId": "6512345678",
"campaignStatus": "paused"
}
{
"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."
]
}
{
"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."
}
Google Ads
Google Performance Max キャンペーン
テキストと画像から Google Ads の Performance Max キャンペーンを作成します
POST
/
ads
/
google
/
campaigns
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"]
}
}
}
}'
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);
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
$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;
}
?>
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);
}
}
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))
}
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());
}
}
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
{
"status": "success",
"platform": "google",
"campaignId": "21534567891",
"assetGroupId": "6512345678",
"campaignStatus": "paused"
}
{
"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."
]
}
{
"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."
}
まずコンバージョン トラッキングを設定してください。 Performance Max は、コンバージョンを使用して広告を表示する場所と入札額を決定します。Ayrshare はコンバージョン トラッキングのないキャンペーンをブロックしませんが、Google Ads アカウントでコンバージョン トラッキングが設定されるまで、Google がキャンペーンの費用を制限する場合があります。Ayrshare が代わりに設定することはありません。アカウントにコンバージョン トラッキングがない場合、作成レスポンスにはその旨を示す
warnings エントリが含まれます。- Google 広告はアカウントごとに有効化されます。有効化するには、お問い合わせください。
status: "active"を送信しない限り、新しいキャンペーンはpausedの状態で開始されます。- 予算は1日あたりの金額で、広告アカウントの通貨で指定します。他のキャンペーンと共有されることはありません。
- 他の通貨での支出は、Open Exchange Rates のその日の為替レートで USD に換算されて請求されます。換算できない通貨のアカウントでは、何も作成される前に
code: 101が返されます。 - 動画はサポートされていません。Google が画像から動画を作成する場合があります。
ヘッダーパラメータ
string
必須
新しいキャンペーンごとに、UUID などの新しい一意の値を指定します。同じキーでリクエストを繰り返すと、最初のレスポンスが返されます。Ayrshare がキャンペーンを Google に送信する前に作成が失敗した場合(たとえば、画像のサイズが正しくない場合)はキーが解放されるため、リクエストを修正して同じキーで再試行できます。
ボディパラメータ
string
必須
performanceMax。object
必須
Performance Max で使用できるのは次の戦略のみです。それ以外を指定すると
code: 101 が返されます。maximizeConversions: 予算内でコンバージョン数を最大化します。targetCpa(targetCpaを指定): 同様に、指定したコンバージョン単価を目標にします。maximizeConversionValue: 予算内でコンバージョン値を最大化します。targetRoas(targetRoasを指定): 同様に、指定した広告費用対効果を目標にします。たとえば 350% の場合は3.5です。
boolean
必須
Google はすべてのキャンペーンでこの申告を必須としています。
string[]
Google の地域 ID。たとえば、米国は
2840 です。省略するとすべての地域がターゲットになります。object
必須
表示 プロパティ
表示 プロパティ
string
必須
広告で開く
http または https のページ。object
必須
テキストと画像。各リストの項目は互いに異なる必要があります。
表示 プロパティ
表示 プロパティ
string[]
必須
3〜15個。各30文字以内です。
string[]
必須
1〜5個。各90文字以内です。
string[]
必須
2〜5個。各90文字以内です。少なくとも1つは60文字以内である必要があります。
string
必須
1つのビジネス名。25文字以内です。
string[]
必須
1〜20個の横長画像の URL: 1.91:1、600×314 以上。
string[]
必須
1〜20個の正方形画像の URL: 1:1、300×300 以上。
string[]
必須
1〜5個の正方形ロゴの URL: 1:1、128×128 以上。
string[]
最大4個の横長ロゴの URL: 4:1、512×128 以上。Google が受け付けるロゴと横長ロゴは合計で最大5個です。
画像
Ayrshare は、Google に何かを送信する前に、各画像を URL からダウンロードして確認します:- GIF、JPG、または PNG で、それぞれ 5120 KB 以内。
- 上記の最小サイズ以上で、フィールドに対応するアスペクト比(誤差 1% 以内)であること。
- すべての画像の合計が 45 MB 以内。
- URL は公開されている必要があります。プライベートアドレスは拒否されます。
code: 101 が返されます。例: platformOptions.google.assets.logos[0]: the image is 100x100; use at least 128x128.
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"]
}
}
}
}'
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);
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
$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;
}
?>
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);
}
}
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))
}
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());
}
}
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
{
"status": "success",
"platform": "google",
"campaignId": "21534567891",
"assetGroupId": "6512345678",
"campaignStatus": "paused"
}
{
"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."
]
}
{
"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."
}