일반적인 트래피킹 작업

이 페이지에서는 DCM/DFA Reporting API 및 Trafficking API를 사용하여 가장 일반적인 트래피킹 작업을 수행하는 방법을 설명합니다.

일반적인 코딩 도움말

  • 필수 및 선택적 속성 및 매개변수 - 참조 문서를 확인하여 API 호출에 속성 또는 매개변수가 필요한지 확인합니다.
  • 와일드 카드 이름 검색 - 객체 이름으로 검색할 때 별표 (*) 와일드 카드를 사용할 수 있습니다. 별표는 0개 이상의 문자와 일치합니다. API는 암시적 하위 문자열 검색도 지원하므로 'abc'를 검색하면 암시적으로 '*abc*'가 검색됩니다.
  • 업데이트와 패치 - 기존 객체를 수정하는 방법에는 두 가지가 있습니다.
    1. 업데이트 - 객체를 업데이트할 때 삽입 시 모든 필드가 덮어쓰여집니다. 업데이트하려는 객체를 로드하고 해당 객체를 변경하는 것이 중요합니다. 그렇지 않으면 업데이트 요청에 없는 필드는 설정 해제됩니다.
    2. 패치 - 패치 시 지정된 필드만 삽입 시 덮어쓰여집니다. 이 경우 새 객체를 만들고 업데이트할 객체와 동일한 ID를 할당하고 업데이트할 필드를 설정하고 패치 요청을 실행하면 됩니다.
  • 크기 - 실제 크기는 크기 서비스로 정의된 Size 객체로 표현됩니다. 계정에서 표준 크기 세트를 제공하며 이 목록에 맞춤 크기를 추가할 수 있습니다.
  • 날짜 및 시간 - 현지 시간대를 사용하여 RFC 3339 형식으로 날짜/시간을 저장할 수 있습니다. API에서 반환되는 모든 값은 UTC입니다. 날짜와 시간이 구성된 시간대 (기본적으로 America/New York 시간)로 표시되는 웹사이트와는 다릅니다.

광고주 만들기

C#

  1. Advertiser 객체를 만들고 필수 namestatus 속성을 설정합니다.
    // Create the advertiser structure.
    Advertiser advertiser = new Advertiser();
    advertiser.Name = advertiserName;
    advertiser.Status = "APPROVED";
  2. advertisers.insert()를 호출하여 광고주를 저장합니다.
    // Create the advertiser.
    Advertiser result = service.Advertisers.Insert(advertiser, profileId).Execute();

자바

  1. Advertiser 객체를 만들고 필수 namestatus 속성을 설정합니다.
    // Create the advertiser structure.
    Advertiser advertiser = new Advertiser();
    advertiser.setName(advertiserName);
    advertiser.setStatus("APPROVED");
  2. advertisers.insert()를 호출하여 광고주를 저장합니다.
    // Create the advertiser.
    Advertiser result = reporting.advertisers().insert(profileId, advertiser).execute();

PHP

  1. Advertiser 객체를 만들고 필수 namestatus 속성을 설정합니다.
    $advertiser = new Google_Service_Dfareporting_Advertiser();
    $advertiser->setName($values['advertiser_name']);
    $advertiser->setStatus('APPROVED');
  2. advertisers.insert()를 호출하여 광고주를 저장합니다.
    $result = $this->service->advertisers->insert(
        $values['user_profile_id'],
        $advertiser
    );

Python

  1. Advertiser 객체를 만들고 필수 namestatus 속성을 설정합니다.
    # Construct and save advertiser.
    advertiser = {
        'name': 'Test Advertiser',
        'status': 'APPROVED'
    }
  2. advertisers.insert()를 호출하여 광고주를 저장합니다.
    request = service.advertisers().insert(
        profileId=profile_id, body=advertiser)
    
    # Execute request and print response.
    response = request.execute()

Ruby

  1. Advertiser 객체를 만들고 필수 namestatus 속성을 설정합니다.
    # Create a new advertiser resource to insert.
    advertiser = DfareportingUtils::API_NAMESPACE::Advertiser.new(
      name: format('Example Advertiser #%s', SecureRandom.hex(3)),
      status: 'APPROVED'
    )
  2. advertisers.insert()를 호출하여 광고주를 저장합니다.
    # Insert the advertiser.
    result = service.insert_advertiser(profile_id, advertiser)

캠페인 만들기

C#

  1. Campaign 객체를 만들고 필수 속성을 설정합니다.

    • advertiserId - 이 캠페인과 연결할 광고주입니다.
    • name - 이 값은 이 광고주의 모든 캠페인에서 고유해야 합니다.
    • defaultLandingPageId - 이 캠페인의 광고에 할당된 방문 페이지가 없는 경우 사용자가 광고를 클릭하면 연결되는 방문 페이지입니다. advertiserLandingPages.list를 호출하여 기존 방문 페이지를 조회하거나 advertiserLandingPages.insert를 호출하여 새 방문 페이지를 만들 수 있습니다.
    • 시작일종료일 - 미래 날짜여야 하며, 날짜까지 정확해야 합니다. 자세한 내용은 일반 코딩 정보의 날짜 및 시간 글머리 기호를 참고하세요. 개별 광고 날짜는 종료일을 초과할 수 있습니다. 이는 게시자가 지정된 캠페인 종료일까지 계약을 이행하지 못한 경우 지정된 수의 액션에 대한 계약을 이행할 수 있도록 하기 위함입니다.
    // Locate an advertiser landing page to use as a default.
    LandingPage defaultLandingPage = getAdvertiserLandingPage(service, profileId, advertiserId);
    
    // Create the campaign structure.
    Campaign campaign = new Campaign();
    campaign.Name = campaignName;
    campaign.AdvertiserId = advertiserId;
    campaign.Archived = false;
    campaign.DefaultLandingPageId = defaultLandingPage.Id;
    
    // Set the campaign start date. This example uses today's date.
    campaign.StartDate =
        DfaReportingDateConverterUtil.convertToDateString(DateTime.Now);
    
    // Set the campaign end date. This example uses one month from today's date.
    campaign.EndDate =
        DfaReportingDateConverterUtil.convertToDateString(DateTime.Now.AddMonths(1));
  2. campaigns.insert()를 호출하여 캠페인을 저장합니다.

    // Insert the campaign.
    Campaign result = service.Campaigns.Insert(campaign, profileId).Execute();

자바

  1. Campaign 객체를 만들고 필수 속성을 설정합니다.

    • advertiserId - 이 캠페인과 연결할 광고주입니다.
    • name - 이 값은 이 광고주의 모든 캠페인에서 고유해야 합니다.
    • defaultLandingPageId - 이 캠페인의 광고에 할당된 방문 페이지가 없는 경우 사용자가 광고를 클릭하면 연결되는 방문 페이지입니다. advertiserLandingPages.list를 호출하여 기존 방문 페이지를 조회하거나 advertiserLandingPages.insert를 호출하여 새 방문 페이지를 만들 수 있습니다.
    • 시작일종료일 - 미래 날짜여야 하며, 날짜까지 정확해야 합니다. 자세한 내용은 일반 코딩 정보의 날짜 및 시간 글머리 기호를 참고하세요. 개별 광고 날짜는 종료일을 초과할 수 있습니다. 이는 게시자가 지정된 캠페인 종료일까지 계약을 이행하지 못한 경우 지정된 수의 액션에 대한 계약을 이행할 수 있도록 하기 위함입니다.
    // Locate an advertiser landing page to use as a default.
    LandingPage defaultLandingPage = getAdvertiserLandingPage(reporting, profileId, advertiserId);
    
    // Create the campaign structure.
    Campaign campaign = new Campaign();
    campaign.setName(campaignName);
    campaign.setAdvertiserId(advertiserId);
    campaign.setArchived(false);
    campaign.setDefaultLandingPageId(defaultLandingPage.getId());
    
    // Set the campaign start date. This example uses today's date.
    Calendar today = Calendar.getInstance();
    DateTime startDate = new DateTime(true, today.getTimeInMillis(), null);
    campaign.setStartDate(startDate);
    
    // Set the campaign end date. This example uses one month from today's date.
    Calendar nextMonth = Calendar.getInstance();
    nextMonth.add(Calendar.MONTH, 1);
    DateTime endDate = new DateTime(true, nextMonth.getTimeInMillis(), null);
    campaign.setEndDate(endDate);
  2. campaigns.insert()를 호출하여 캠페인을 저장합니다.

    // Insert the campaign.
    Campaign result = reporting.campaigns().insert(profileId, campaign).execute();

PHP

  1. Campaign 객체를 만들고 필수 속성을 설정합니다.

    • advertiserId - 이 캠페인과 연결할 광고주입니다.
    • name - 이 값은 이 광고주의 모든 캠페인에서 고유해야 합니다.
    • defaultLandingPageId - 이 캠페인의 광고에 할당된 방문 페이지가 없는 경우 사용자가 광고를 클릭하면 연결되는 방문 페이지입니다. advertiserLandingPages.list를 호출하여 기존 방문 페이지를 조회하거나 advertiserLandingPages.insert를 호출하여 새 방문 페이지를 만들 수 있습니다.
    • 시작일종료일 - 미래 날짜여야 하며, 날짜까지 정확해야 합니다. 자세한 내용은 일반 코딩 정보의 날짜 및 시간 글머리 기호를 참고하세요. 개별 광고 날짜는 종료일을 초과할 수 있습니다. 이는 게시자가 지정된 캠페인 종료일까지 계약을 이행하지 못한 경우 지정된 수의 액션에 대한 계약을 이행할 수 있도록 하기 위함입니다.
    $startDate = new DateTime('today');
    $endDate = new DateTime('+1 month');
    
    $campaign = new Google_Service_Dfareporting_Campaign();
    $campaign->setAdvertiserId($values['advertiser_id']);
    $campaign->setDefaultLandingPageId($values['default_landing_page_id']);
    $campaign->setName($values['campaign_name']);
    $campaign->setStartDate($startDate->format('Y-m-d'));
    $campaign->setEndDate($endDate->format('Y-m-d'));
  2. campaigns.insert()를 호출하여 캠페인을 저장합니다.

    $result = $this->service->campaigns->insert(
        $values['user_profile_id'],
        $campaign
    );

Python

  1. Campaign 객체를 만들고 필수 속성을 설정합니다.

    • advertiserId - 이 캠페인과 연결할 광고주입니다.
    • name - 이 값은 이 광고주의 모든 캠페인에서 고유해야 합니다.
    • defaultLandingPageId - 이 캠페인의 광고에 할당된 방문 페이지가 없는 경우 사용자가 광고를 클릭하면 연결되는 방문 페이지입니다. advertiserLandingPages.list를 호출하여 기존 방문 페이지를 조회하거나 advertiserLandingPages.insert를 호출하여 새 방문 페이지를 만들 수 있습니다.
    • 시작일종료일 - 미래 날짜여야 하며, 날짜까지 정확해야 합니다. 자세한 내용은 일반 코딩 정보의 날짜 및 시간 글머리 기호를 참고하세요. 개별 광고 날짜는 종료일을 초과할 수 있습니다. 이는 게시자가 지정된 캠페인 종료일까지 계약을 이행하지 못한 경우 지정된 수의 액션에 대한 계약을 이행할 수 있도록 하기 위함입니다.
    # Locate an advertiser landing page to use as a default.
    default_landing_page = get_advertiser_landing_page(service, profile_id,
                                                       advertiser_id)
    
    # Construct and save campaign.
    campaign = {
        'name': 'Test Campaign #%s' % uuid.uuid4(),
        'advertiserId': advertiser_id,
        'archived': 'false',
        'defaultLandingPageId': default_landing_page['id'],
        'startDate': '2015-01-01',
        'endDate': '2020-01-01'
    }
  2. campaigns.insert()를 호출하여 캠페인을 저장합니다.

    request = service.campaigns().insert(profileId=profile_id, body=campaign)
    
    # Execute request and print response.
    response = request.execute()

Ruby

  1. Campaign 객체를 만들고 필수 속성을 설정합니다.

    • advertiserId - 이 캠페인과 연결할 광고주입니다.
    • name - 이 값은 이 광고주의 모든 캠페인에서 고유해야 합니다.
    • defaultLandingPageId - 이 캠페인의 광고에 할당된 방문 페이지가 없는 경우 사용자가 광고를 클릭하면 연결되는 방문 페이지입니다. advertiserLandingPages.list를 호출하여 기존 방문 페이지를 조회하거나 advertiserLandingPages.insert를 호출하여 새 방문 페이지를 만들 수 있습니다.
    • 시작일종료일 - 미래 날짜여야 하며, 날짜까지 정확해야 합니다. 자세한 내용은 일반 코딩 정보의 날짜 및 시간 글머리 기호를 참고하세요. 개별 광고 날짜는 종료일을 초과할 수 있습니다. 이는 게시자가 지정된 캠페인 종료일까지 계약을 이행하지 못한 경우 지정된 수의 액션에 대한 계약을 이행할 수 있도록 하기 위함입니다.
    # Locate an advertiser landing page to use as a default.
    default_landing_page = get_advertiser_landing_page(service, profile_id,
      advertiser_id)
    
    # Create a new campaign resource to insert.
    campaign = DfareportingUtils::API_NAMESPACE::Campaign.new(
      advertiser_id: advertiser_id,
      archived: false,
      default_landing_page_id: default_landing_page.id,
      name: format('Example Campaign #%s', SecureRandom.hex(3)),
      start_date: '2014-01-01',
      end_date: '2020-01-01'
    )
  2. campaigns.insert()를 호출하여 캠페인을 저장합니다.

    # Insert the campaign.
    result = service.insert_campaign(profile_id, campaign)

게재위치 만들기

C#

  1. Placement 객체를 만들고 필수 게재위치 속성 (campaignIdsiteId 포함)을 설정합니다. 또한 웹사이트와 협상한 게재위치의 게재위치 유형과 크기를 정확하게 설정해야 합니다.
    // Create the placement.
    Placement placement = new Placement();
    placement.Name = placementName;
    placement.CampaignId = campaignId;
    placement.Compatibility = "DISPLAY";
    placement.PaymentSource = "PLACEMENT_AGENCY_PAID";
    placement.SiteId = dfaSiteId;
    placement.TagFormats = new List<string>() { "PLACEMENT_TAG_STANDARD" };
    
    // Set the size of the placement.
    Size size = new Size();
    size.Id = sizeId;
    placement.Size = size;
  2. 게재위치에 할당할 새 PricingSchedule 객체를 만듭니다.
    // Set the pricing schedule for the placement.
    PricingSchedule pricingSchedule = new PricingSchedule();
    pricingSchedule.EndDate = campaign.EndDate;
    pricingSchedule.PricingType = "PRICING_TYPE_CPM";
    pricingSchedule.StartDate = campaign.StartDate;
    placement.PricingSchedule = pricingSchedule;
  3. placements.insert()를 호출하여 Placement 객체를 저장합니다. 반환된 ID를 광고 또는 광고 소재에 할당하려면 저장해야 합니다.
    // Insert the placement.
    Placement result = service.Placements.Insert(placement, profileId).Execute();

자바

  1. Placement 객체를 만들고 필수 게재위치 속성 (campaignIdsiteId 포함)을 설정합니다. 또한 웹사이트와 협상한 게재위치의 게재위치 유형과 크기를 정확하게 설정해야 합니다.
    // Create the placement.
    Placement placement = new Placement();
    placement.setName(placementName);
    placement.setCampaignId(campaignId);
    placement.setCompatibility("DISPLAY");
    placement.setPaymentSource("PLACEMENT_AGENCY_PAID");
    placement.setSiteId(dfaSiteId);
    placement.setTagFormats(ImmutableList.of("PLACEMENT_TAG_STANDARD"));
    
    // Set the size of the placement.
    Size size = new Size();
    size.setId(sizeId);
    placement.setSize(size);
  2. 게재위치에 할당할 새 PricingSchedule 객체를 만듭니다.
    // Set the pricing schedule for the placement.
    PricingSchedule pricingSchedule = new PricingSchedule();
    pricingSchedule.setEndDate(campaign.getEndDate());
    pricingSchedule.setPricingType("PRICING_TYPE_CPM");
    pricingSchedule.setStartDate(campaign.getStartDate());
    placement.setPricingSchedule(pricingSchedule);
  3. placements.insert()를 호출하여 Placement 객체를 저장합니다. 반환된 ID를 광고 또는 광고 소재에 할당하려면 저장해야 합니다.
    // Insert the placement.
    Placement result = reporting.placements().insert(profileId, placement).execute();

PHP

  1. Placement 객체를 만들고 필수 게재위치 속성 (campaignIdsiteId 포함)을 설정합니다. 또한 웹사이트와 협상한 게재위치의 게재위치 유형과 크기를 정확하게 설정해야 합니다.
    $placement = new Google_Service_Dfareporting_Placement();
    $placement->setCampaignId($values['campaign_id']);
    $placement->setCompatibility('DISPLAY');
    $placement->setName($values['placement_name']);
    $placement->setPaymentSource('PLACEMENT_AGENCY_PAID');
    $placement->setSiteId($values['site_id']);
    $placement->setTagFormats(['PLACEMENT_TAG_STANDARD']);
    
    // Set the size of the placement.
    $size = new Google_Service_Dfareporting_Size();
    $size->setId($values['size_id']);
    $placement->setSize($size);
  2. 게재위치에 할당할 새 PricingSchedule 객체를 만듭니다.
    // Set the pricing schedule for the placement.
    $pricingSchedule = new Google_Service_Dfareporting_PricingSchedule();
    $pricingSchedule->setEndDate($campaign->getEndDate());
    $pricingSchedule->setPricingType('PRICING_TYPE_CPM');
    $pricingSchedule->setStartDate($campaign->getStartDate());
    $placement->setPricingSchedule($pricingSchedule);
  3. placements.insert()를 호출하여 Placement 객체를 저장합니다. 반환된 ID를 광고 또는 광고 소재에 할당하려면 저장해야 합니다.
    // Insert the placement.
    $result = $this->service->placements->insert(
        $values['user_profile_id'],
        $placement
    );

Python

  1. Placement 객체를 만들고 필수 게재위치 속성 (campaignIdsiteId 포함)을 설정합니다. 또한 웹사이트와 협상한 게재위치의 게재위치 유형과 크기를 정확하게 설정해야 합니다.
    # Construct and save placement.
    placement = {
        'name': 'Test Placement',
        'campaignId': campaign_id,
        'compatibility': 'DISPLAY',
        'siteId': site_id,
        'size': {
            'height': '1',
            'width': '1'
        },
        'paymentSource': 'PLACEMENT_AGENCY_PAID',
        'tagFormats': ['PLACEMENT_TAG_STANDARD']
    }
  2. 게재위치에 할당할 새 PricingSchedule 객체를 만듭니다.
    # Set the pricing schedule for the placement.
    placement['pricingSchedule'] = {
        'startDate': campaign['startDate'],
        'endDate': campaign['endDate'],
        'pricingType': 'PRICING_TYPE_CPM'
    }
  3. placements.insert()를 호출하여 Placement 객체를 저장합니다. 반환된 ID를 광고 또는 광고 소재에 할당하려면 저장해야 합니다.
    request = service.placements().insert(profileId=profile_id, body=placement)
    
    # Execute request and print response.
    response = request.execute()

Ruby

  1. Placement 객체를 만들고 필수 게재위치 속성 (campaignIdsiteId 포함)을 설정합니다. 또한 웹사이트와 협상한 게재위치의 게재위치 유형과 크기를 정확하게 설정해야 합니다.
    # Create a new placement resource to insert.
    placement = DfareportingUtils::API_NAMESPACE::Placement.new(
      campaign_id: campaign_id,
      compatibility: 'DISPLAY',
      name: 'Example Placement',
      payment_source: 'PLACEMENT_AGENCY_PAID',
      site_id: site_id,
      size: DfareportingUtils::API_NAMESPACE::Size.new(
        height: 1,
        width: 1
      ),
      tag_formats: ['PLACEMENT_TAG_STANDARD']
    )
  2. 게재위치에 할당할 새 PricingSchedule 객체를 만듭니다.
    # Set the pricing schedule for the placement.
    placement.pricing_schedule =
      DfareportingUtils::API_NAMESPACE::PricingSchedule.new(
        end_date: campaign.end_date,
        pricing_type: 'PRICING_TYPE_CPM',
        start_date: campaign.start_date
      )
  3. placements.insert()를 호출하여 Placement 객체를 저장합니다. 반환된 ID를 광고 또는 광고 소재에 할당하려면 저장해야 합니다.
    # Insert the placement strategy.
    result = service.insert_placement(profile_id, placement)

애셋 업로드

미디어 업로드라는 프로세스를 통해 다양한 유형의 확장 소재를 업로드할 수 있습니다. 이 프로세스는 모든 광고 소재 유형에서 유사하지만 일부 유형은 올바르게 사용하려면 특정 속성을 메타데이터로 전달해야 할 수 있습니다.

C#

  1. assetIdentifier 객체를 만들고 필수 속성을 설정합니다. 모든 애셋은 유형이나 사용 방식과 관계없이 assetIdentifier를 지정해야 합니다. 광고 소재에 애셋을 할당할 때 이 객체는 애셋을 다시 참조하는 데 사용됩니다. 다음 속성은 필수입니다.

    • name 속성(서버의 애셋 이름) 이름에는 .png 또는 .gif와 같은 파일 형식을 나타내는 확장자가 포함되어야 하며, 브라우저에 애셋 이름으로 표시되지만 원본 파일 이름과 동일하지 않아도 됩니다. 이 이름은 서버에서 고유하도록 Campaign Manager 360에 의해 변경될 수 있습니다. 반환 값을 확인하여 변경되었는지 확인하세요.
    • type 속성(애셋 유형을 식별함) 이 속성은 이 애셋과 연결할 수 있는 광고 소재의 유형을 지정합니다.
    // Create the creative asset ID and Metadata.
    CreativeAssetId assetId = new CreativeAssetId();
    assetId.Name = Path.GetFileName(assetFile);
    assetId.Type = assetType;
  2. creativeAssets.insert()를 호출하여 파일을 업로드합니다. assetIdentifier와 파일 콘텐츠를 동일한 요청의 일부로 전달하여 멀티파트 업로드를 실행합니다. 성공하면 이 애셋을 광고 소재에 할당하는 데 사용할 assetIdentifier과 함께 CreativeAsset 리소스가 반환됩니다.

    // Prepare an input stream.
    FileStream assetContent = new FileStream(assetFile, FileMode.Open, FileAccess.Read);
    
    
    CreativeAssetMetadata metaData = new CreativeAssetMetadata();
    metaData.AssetIdentifier = assetId;
    
    // Insert the creative.
    String mimeType = determineMimeType(assetFile, assetType);
    CreativeAssetsResource.InsertMediaUpload request =
        Service.CreativeAssets.Insert(metaData, ProfileId, AdvertiserId, assetContent, mimeType);
    
    IUploadProgress progress = request.Upload();
    if (UploadStatus.Failed.Equals(progress.Status)) {
        throw progress.Exception;
    }

자바

  1. assetIdentifier 객체를 만들고 필수 속성을 설정합니다. 모든 애셋은 유형이나 사용 방식과 관계없이 assetIdentifier를 지정해야 합니다. 광고 소재에 애셋을 할당할 때 이 객체는 애셋을 다시 참조하는 데 사용됩니다. 다음 속성은 필수입니다.

    • name 속성(서버의 애셋 이름) 이름에는 .png 또는 .gif와 같은 파일 형식을 나타내는 확장자가 포함되어야 하며, 브라우저에 애셋 이름으로 표시되지만 원본 파일 이름과 동일하지 않아도 됩니다. 이 이름은 서버에서 고유하도록 Campaign Manager 360에 의해 변경될 수 있습니다. 반환 값을 확인하여 변경되었는지 확인하세요.
    • type 속성(애셋 유형을 식별함) 이 속성은 이 애셋과 연결할 수 있는 광고 소재의 유형을 지정합니다.
    // Create the creative asset ID and Metadata.
    CreativeAssetId assetId = new CreativeAssetId();
    assetId.setName(assetName);
    assetId.setType(assetType);
  2. creativeAssets.insert()를 호출하여 파일을 업로드합니다. assetIdentifier와 파일 콘텐츠를 동일한 요청의 일부로 전달하여 멀티파트 업로드를 실행합니다. 성공하면 이 애셋을 광고 소재에 할당하는 데 사용할 assetIdentifier과 함께 CreativeAsset 리소스가 반환됩니다.

    // Open the asset file.
    File file = new File(assetFile);
    
    // Prepare an input stream.
    String contentType = getMimeType(assetFile);
    InputStreamContent assetContent =
        new InputStreamContent(contentType, new BufferedInputStream(new FileInputStream(file)));
    assetContent.setLength(file.length());
    
    
    CreativeAssetMetadata metaData = new CreativeAssetMetadata();
    metaData.setAssetIdentifier(assetId);
    
    // Insert the creative.
    CreativeAssetMetadata result = reporting.creativeAssets()
        .insert(profileId, advertiserId, metaData, assetContent).execute();

PHP

  1. assetIdentifier 객체를 만들고 필수 속성을 설정합니다. 모든 애셋은 유형이나 사용 방식과 관계없이 assetIdentifier를 지정해야 합니다. 광고 소재에 애셋을 할당할 때 이 객체는 애셋을 다시 참조하는 데 사용됩니다. 다음 속성은 필수입니다.

    • name 속성(서버의 애셋 이름) 이름에는 .png 또는 .gif와 같은 파일 형식을 나타내는 확장자가 포함되어야 하며, 브라우저에 애셋 이름으로 표시되지만 원본 파일 이름과 동일하지 않아도 됩니다. 이 이름은 서버에서 고유하도록 Campaign Manager 360에 의해 변경될 수 있습니다. 반환 값을 확인하여 변경되었는지 확인하세요.
    • type 속성(애셋 유형을 식별함) 이 속성은 이 애셋과 연결할 수 있는 광고 소재의 유형을 지정합니다.
    $assetId = new Google_Service_Dfareporting_CreativeAssetId();
    $assetId->setName($asset['name']);
    $assetId->setType($type);
  2. creativeAssets.insert()를 호출하여 파일을 업로드합니다. assetIdentifier와 파일 콘텐츠를 동일한 요청의 일부로 전달하여 멀티파트 업로드를 실행합니다. 성공하면 이 애셋을 광고 소재에 할당하는 데 사용할 assetIdentifier과 함께 CreativeAsset 리소스가 반환됩니다.

    $metadata = new Google_Service_Dfareporting_CreativeAssetMetadata();
    $metadata->setAssetIdentifier($assetId);
    
    $result = $service->creativeAssets->insert(
        $userProfileId,
        $advertiserId,
        $metadata,
        ['data' => file_get_contents($asset['tmp_name']),
         'mimeType' => $asset['type'],
         'uploadType' => 'multipart']
    );

Python

  1. assetIdentifier 객체를 만들고 필수 속성을 설정합니다. 모든 애셋은 유형이나 사용 방식과 관계없이 assetIdentifier를 지정해야 합니다. 광고 소재에 애셋을 할당할 때 이 객체는 애셋을 다시 참조하는 데 사용됩니다. 다음 속성은 필수입니다.

    • name 속성(서버의 애셋 이름) 이름에는 .png 또는 .gif와 같은 파일 형식을 나타내는 확장자가 포함되어야 하며, 브라우저에 애셋 이름으로 표시되지만 원본 파일 이름과 동일하지 않아도 됩니다. 이 이름은 서버에서 고유하도록 Campaign Manager 360에 의해 변경될 수 있습니다. 반환 값을 확인하여 변경되었는지 확인하세요.
    • type 속성(애셋 유형을 식별함) 이 속성은 이 애셋과 연결할 수 있는 광고 소재의 유형을 지정합니다.
    # Construct the creative asset metadata
    creative_asset = {'assetIdentifier': {'name': asset_name, 'type': asset_type}}
  2. creativeAssets.insert()를 호출하여 파일을 업로드합니다. assetIdentifier와 파일 콘텐츠를 동일한 요청의 일부로 전달하여 멀티파트 업로드를 실행합니다. 성공하면 이 애셋을 광고 소재에 할당하는 데 사용할 assetIdentifier과 함께 CreativeAsset 리소스가 반환됩니다.

    media = MediaFileUpload(path_to_asset_file)
    if not media.mimetype():
      media = MediaFileUpload(path_to_asset_file, 'application/octet-stream')
    
    response = service.creativeAssets().insert(
        advertiserId=advertiser_id,
        profileId=profile_id,
        media_body=media,
        body=creative_asset).execute()

Ruby

  1. assetIdentifier 객체를 만들고 필수 속성을 설정합니다. 모든 애셋은 유형이나 사용 방식과 관계없이 assetIdentifier를 지정해야 합니다. 광고 소재에 애셋을 할당할 때 이 객체는 애셋을 다시 참조하는 데 사용됩니다. 다음 속성은 필수입니다.

    • name 속성(서버의 애셋 이름) 이름에는 .png 또는 .gif와 같은 파일 형식을 나타내는 확장자가 포함되어야 하며, 브라우저에 애셋 이름으로 표시되지만 원본 파일 이름과 동일하지 않아도 됩니다. 이 이름은 서버에서 고유하도록 Campaign Manager 360에 의해 변경될 수 있습니다. 반환 값을 확인하여 변경되었는지 확인하세요.
    • type 속성(애셋 유형을 식별함) 이 속성은 이 애셋과 연결할 수 있는 광고 소재의 유형을 지정합니다.
    # Construct the creative asset metadata
    creative_asset = DfareportingUtils::API_NAMESPACE::CreativeAsset.new(
      asset_identifier: DfareportingUtils::API_NAMESPACE::CreativeAssetId.new(
        name: asset_name,
        type: asset_type
      )
    )
  2. creativeAssets.insert()를 호출하여 파일을 업로드합니다. assetIdentifier와 파일 콘텐츠를 동일한 요청의 일부로 전달하여 멀티파트 업로드를 실행합니다. 성공하면 이 애셋을 광고 소재에 할당하는 데 사용할 assetIdentifier과 함께 CreativeAsset 리소스가 반환됩니다.

    # Upload the asset.
    mime_type = determine_mime_type(path_to_asset_file, asset_type)
    
    result = @service.insert_creative_asset(
      @profile_id,
      advertiser_id,
      creative_asset,
      content_type: mime_type,
      upload_source: path_to_asset_file
    )

광고 소재 만들기

Creative 객체는 기존 애셋을 래핑합니다. 호스트 페이지에서 광고 소재를 사용하는 방법에 따라 다양한 광고 소재 유형의 Creative 객체를 만들 수 있습니다. 참고 문서를 참고하여 적합한 유형을 확인하세요.

다음 예에서는 새 HTML5 디스플레이 광고 소재를 만드는 방법을 보여줍니다.

C#

  1. 애셋을 업로드합니다. 광고 소재마다 필요한 애셋의 유형과 수량이 다릅니다. 자세한 내용은 애셋 업로드를 참고하세요. 애셋을 업로드할 때마다 응답에 assetIdenfitier가 표시됩니다. 기존 ID 대신 저장된 파일 이름과 유형을 사용하여 광고 소재에서 이러한 애셋을 참조합니다.
  2. 광고 소재를 만들고 적절한 값을 할당합니다. Creative를 인스턴스화하고 적절한 type를 설정합니다. Creative 객체의 유형은 저장한 후에는 변경할 수 없습니다. AssetIdentifierrole로 애셋을 지정합니다.
    // Locate an advertiser landing page to use as a default.
    LandingPage defaultLandingPage = getAdvertiserLandingPage(service, profileId, advertiserId);
    
    // Create the creative structure.
    Creative creative = new Creative();
    creative.AdvertiserId = advertiserId;
    creative.Name = "Test HTML5 display creative";
    creative.Size = new Size() { Id = sizeId };
    creative.Type = "DISPLAY";
    
    // Upload the HTML5 asset.
    CreativeAssetUtils assetUtils = new CreativeAssetUtils(service, profileId, advertiserId);
    CreativeAssetId html5AssetId =
        assetUtils.uploadAsset(pathToHtml5AssetFile, "HTML").AssetIdentifier;
    
    CreativeAsset html5Asset = new CreativeAsset();
    html5Asset.AssetIdentifier = html5AssetId;
    html5Asset.Role = "PRIMARY";
    
    // Upload the backup image asset.
    CreativeAssetId imageAssetId =
        assetUtils.uploadAsset(pathToImageAssetFile, "HTML_IMAGE").AssetIdentifier;
    
    CreativeAsset imageAsset = new CreativeAsset();
    imageAsset.AssetIdentifier = imageAssetId;
    imageAsset.Role = "BACKUP_IMAGE";
    
    // Add the creative assets.
    creative.CreativeAssets = new List<CreativeAsset>() { html5Asset, imageAsset };
    
    // Configure the bacup image.
    creative.BackupImageClickThroughUrl = new CreativeClickThroughUrl() {
      LandingPageId = defaultLandingPage.Id
    };
    creative.BackupImageReportingLabel = "backup";
    creative.BackupImageTargetWindow = new TargetWindow() { TargetWindowOption = "NEW_WINDOW" };
    
    // Add a click tag.
    ClickTag clickTag = new ClickTag();
    clickTag.Name = "clickTag";
    clickTag.EventName = "exit";
    clickTag.ClickThroughUrl = new CreativeClickThroughUrl() {
      LandingPageId = defaultLandingPage.Id
    };
    creative.ClickTags = new List<ClickTag>() { clickTag };
  3. 광고 소재를 저장합니다. creatives.insert()을 호출하면 됩니다. 이 광고 소재와 연결할 광고주 ID를 지정해야 합니다.
    Creative result = service.Creatives.Insert(creative, profileId).Execute();
  4. (선택사항) 광고 소재를 캠페인과 연결합니다. 캠페인 및 광고 소재 ID를 전달하여 campaignCreativeAssociations.insert()을 호출하면 됩니다.
    // Create the campaign creative association structure.
    CampaignCreativeAssociation association = new CampaignCreativeAssociation();
    association.CreativeId = creativeId;
    
    // Insert the association.
    CampaignCreativeAssociation result =
        service.CampaignCreativeAssociations.Insert(association, profileId, campaignId).Execute();

자바

  1. 애셋을 업로드합니다. 광고 소재마다 필요한 애셋의 유형과 수량이 다릅니다. 자세한 내용은 애셋 업로드를 참고하세요. 애셋을 업로드할 때마다 응답에 assetIdenfitier가 표시됩니다. 기존 ID 대신 저장된 파일 이름과 유형을 사용하여 광고 소재에서 이러한 애셋을 참조합니다.
  2. 광고 소재를 만들고 적절한 값을 할당합니다. Creative를 인스턴스화하고 적절한 type를 설정합니다. Creative 객체의 유형은 저장한 후에는 변경할 수 없습니다. AssetIdentifierrole로 애셋을 지정합니다.
    // Locate an advertiser landing page to use as a default.
    LandingPage defaultLandingPage = getAdvertiserLandingPage(reporting, profileId, advertiserId);
    
    // Create the creative structure.
    Creative creative = new Creative();
    creative.setAdvertiserId(advertiserId);
    creative.setName("Test HTML5 display creative");
    creative.setSize(new Size().setId(sizeId));
    creative.setType("DISPLAY");
    
    // Upload the HTML5 asset.
    CreativeAssetId html5AssetId = CreativeAssetUtils.uploadAsset(reporting, profileId,
        advertiserId, HTML5_ASSET_NAME, PATH_TO_HTML5_ASSET_FILE, "HTML").getAssetIdentifier();
    
    CreativeAsset html5Asset =
        new CreativeAsset().setAssetIdentifier(html5AssetId).setRole("PRIMARY");
    
    // Upload the backup image asset (note: asset type must be set to HTML_IMAGE).
    CreativeAssetId imageAssetId = CreativeAssetUtils.uploadAsset(reporting, profileId,
        advertiserId, IMAGE_ASSET_NAME, PATH_TO_IMAGE_ASSET_FILE, "HTML_IMAGE")
        .getAssetIdentifier();
    
    CreativeAsset backupImageAsset =
        new CreativeAsset().setAssetIdentifier(imageAssetId).setRole("BACKUP_IMAGE");
    
    // Add the creative assets.
    creative.setCreativeAssets(ImmutableList.of(html5Asset, backupImageAsset));
    
    // Configure the backup image.
    creative.setBackupImageClickThroughUrl(
        new CreativeClickThroughUrl().setLandingPageId(defaultLandingPage.getId()));
    creative.setBackupImageReportingLabel("backup");
    creative.setBackupImageTargetWindow(new TargetWindow().setTargetWindowOption("NEW_WINDOW"));
    
    // Add a click tag.
    ClickTag clickTag =
        new ClickTag().setName("clickTag").setEventName("exit").setClickThroughUrl(
            new CreativeClickThroughUrl().setLandingPageId(defaultLandingPage.getId()));
    creative.setClickTags(ImmutableList.of(clickTag));
  3. 광고 소재를 저장합니다. creatives.insert()을 호출하면 됩니다. 이 광고 소재와 연결할 광고주 ID를 지정해야 합니다.
    Creative result = reporting.creatives().insert(profileId, creative).execute();
  4. (선택사항) 광고 소재를 캠페인과 연결합니다. 캠페인 및 광고 소재 ID를 전달하여 campaignCreativeAssociations.insert()을 호출하면 됩니다.
    // Create the campaign creative association structure.
    CampaignCreativeAssociation association = new CampaignCreativeAssociation();
    association.setCreativeId(creativeId);
    
    // Insert the association.
    CampaignCreativeAssociation result = reporting
        .campaignCreativeAssociations().insert(profileId, campaignId, association)
        .execute();

PHP

  1. 애셋을 업로드합니다. 광고 소재마다 필요한 애셋의 유형과 수량이 다릅니다. 자세한 내용은 애셋 업로드를 참고하세요. 애셋을 업로드할 때마다 응답에 assetIdenfitier가 표시됩니다. 기존 ID 대신 저장된 파일 이름과 유형을 사용하여 광고 소재에서 이러한 애셋을 참조합니다.
  2. 광고 소재를 만들고 적절한 값을 할당합니다. Creative를 인스턴스화하고 적절한 type를 설정합니다. Creative 객체의 유형은 저장한 후에는 변경할 수 없습니다. AssetIdentifierrole로 애셋을 지정합니다.
    $creative = new Google_Service_Dfareporting_Creative();
    $creative->setAdvertiserId($values['advertiser_id']);
    $creative->setAutoAdvanceImages(true);
    $creative->setName('Test HTML5 display creative');
    $creative->setType('DISPLAY');
    
    $size = new Google_Service_Dfareporting_Size();
    $size->setId($values['size_id']);
    $creative->setSize($size);
    
    // Upload the HTML5 asset.
    $html = uploadAsset(
        $this->service,
        $values['user_profile_id'],
        $values['advertiser_id'],
        $values['html_asset_file'],
        'HTML'
    );
    
    $htmlAsset = new Google_Service_Dfareporting_CreativeAsset();
    $htmlAsset->setAssetIdentifier($html->getAssetIdentifier());
    $htmlAsset->setRole('PRIMARY');
    
    // Upload the backup image asset.
    $image = uploadAsset(
        $this->service,
        $values['user_profile_id'],
        $values['advertiser_id'],
        $values['image_asset_file'],
        'HTML_IMAGE'
    );
    
    $imageAsset = new Google_Service_Dfareporting_CreativeAsset();
    $imageAsset->setAssetIdentifier($image->getAssetIdentifier());
    $imageAsset->setRole('BACKUP_IMAGE');
    
    // Add the creative assets.
    $creative->setCreativeAssets([$htmlAsset, $imageAsset]);
    
    // Configure the default click-through URL.
    $clickThroughUrl =
        new Google_Service_Dfareporting_CreativeClickThroughUrl();
    $clickThroughUrl->setLandingPageId($values['landing_page_id']);
    
    // Configure the backup image.
    $creative->setBackupImageClickThroughUrl($clickThroughUrl);
    $creative->setBackupImageReportingLabel('backup');
    
    $targetWindow = new Google_Service_Dfareporting_TargetWindow();
    $targetWindow->setTargetWindowOption('NEW_WINDOW');
    $creative->setBackupImageTargetWindow($targetWindow);
    
    // Add a click tag.
    $clickTag = new Google_Service_Dfareporting_ClickTag();
    $clickTag->setName('clickTag');
    $clickTag->setEventName('exit');
    $clickTag->setClickThroughUrl($clickThroughUrl);
    $creative->setClickTags([$clickTag]);
  3. 광고 소재를 저장합니다. creatives.insert()을 호출하면 됩니다. 이 광고 소재와 연결할 광고주 ID를 지정해야 합니다.
    $result = $this->service->creatives->insert(
        $values['user_profile_id'],
        $creative
    );
  4. (선택사항) 광고 소재를 캠페인과 연결합니다. 캠페인 및 광고 소재 ID를 전달하여 campaignCreativeAssociations.insert()을 호출하면 됩니다.
    $association =
        new Google_Service_Dfareporting_CampaignCreativeAssociation();
    $association->setCreativeId($values['creative_id']);
    
    $result = $this->service->campaignCreativeAssociations->insert(
        $values['user_profile_id'],
        $values['campaign_id'],
        $association
    );

Python

  1. 애셋을 업로드합니다. 광고 소재마다 필요한 애셋의 유형과 수량이 다릅니다. 자세한 내용은 애셋 업로드를 참고하세요. 애셋을 업로드할 때마다 응답에 assetIdenfitier가 표시됩니다. 기존 ID 대신 저장된 파일 이름과 유형을 사용하여 광고 소재에서 이러한 애셋을 참조합니다.
  2. 광고 소재를 만들고 적절한 값을 할당합니다. Creative를 인스턴스화하고 적절한 type를 설정합니다. Creative 객체의 유형은 저장한 후에는 변경할 수 없습니다. AssetIdentifierrole로 애셋을 지정합니다.
    # Locate an advertiser landing page to use as a default.
    default_landing_page = get_advertiser_landing_page(service, profile_id,
                                                       advertiser_id)
    
    # Upload the HTML5 asset
    html5_asset_id = upload_creative_asset(service, profile_id, advertiser_id,
                                           html5_asset_name,
                                           path_to_html5_asset_file, 'HTML')
    
    # Upload the backup image asset
    backup_image_asset_id = upload_creative_asset(
        service, profile_id, advertiser_id, backup_image_name,
        path_to_backup_image_file, 'HTML_IMAGE')
    
    # Construct the creative structure.
    creative = {
        'advertiserId': advertiser_id,
        'backupImageClickThroughUrl': {
            'landingPageId': default_landing_page['id']
        },
        'backupImageReportingLabel': 'backup_image_exit',
        'backupImageTargetWindow': {'targetWindowOption': 'NEW_WINDOW'},
        'clickTags': [{
            'eventName': 'exit',
            'name': 'click_tag',
            'clickThroughUrl': {'landingPageId': default_landing_page['id']}
        }],
        'creativeAssets': [
            {'assetIdentifier': html5_asset_id, 'role': 'PRIMARY'},
            {'assetIdentifier': backup_image_asset_id, 'role': 'BACKUP_IMAGE'}
        ],
        'name': 'Test HTML5 display creative',
        'size': {'id': size_id},
        'type': 'DISPLAY'
    }
  3. 광고 소재를 저장합니다. creatives.insert()을 호출하면 됩니다. 이 광고 소재와 연결할 광고주 ID를 지정해야 합니다.
    request = service.creatives().insert(profileId=profile_id, body=creative)
    
    # Execute request and print response.
    response = request.execute()
  4. (선택사항) 광고 소재를 캠페인과 연결합니다. 캠페인 및 광고 소재 ID를 전달하여 campaignCreativeAssociations.insert()을 호출하면 됩니다.
    # Construct the request.
    association = {
        'creativeId': creative_id
    }
    
    request = service.campaignCreativeAssociations().insert(
        profileId=profile_id, campaignId=campaign_id, body=association)
    
    # Execute request and print response.
    response = request.execute()

Ruby

  1. 애셋을 업로드합니다. 광고 소재마다 필요한 애셋의 유형과 수량이 다릅니다. 자세한 내용은 애셋 업로드를 참고하세요. 애셋을 업로드할 때마다 응답에 assetIdenfitier가 표시됩니다. 기존 ID 대신 저장된 파일 이름과 유형을 사용하여 광고 소재에서 이러한 애셋을 참조합니다.
  2. 광고 소재를 만들고 적절한 값을 할당합니다. Creative를 인스턴스화하고 적절한 type를 설정합니다. Creative 객체의 유형은 저장한 후에는 변경할 수 없습니다. AssetIdentifierrole로 애셋을 지정합니다.
    # Locate an advertiser landing page to use as a default.
    default_landing_page = get_advertiser_landing_page(service, profile_id,
      advertiser_id)
    
    # Upload the HTML5 asset.
    html5_asset_id = util.upload_asset(advertiser_id, path_to_html5_asset_file,
      'HTML').asset_identifier
    
    # Upload the backup image asset.
    backup_image_asset_id = util.upload_asset(advertiser_id,
      path_to_backup_image_file, 'HTML_IMAGE').asset_identifier
    
    # Construct the creative structure.
    creative = DfareportingUtils::API_NAMESPACE::Creative.new(
      advertiser_id: advertiser_id,
      backup_image_click_through_url:
        DfareportingUtils::API_NAMESPACE::CreativeClickThroughUrl.new(
          landing_page_id: default_landing_page.id
        ),
      backup_image_reporting_label: 'backup',
      backup_image_target_window:
        DfareportingUtils::API_NAMESPACE::TargetWindow.new(
          target_window_option: 'NEW_WINDOW'
        ),
      click_tags: [
        DfareportingUtils::API_NAMESPACE::ClickTag.new(
          event_name: 'exit',
          name: 'click_tag',
          click_through_url:
            DfareportingUtils::API_NAMESPACE::CreativeClickThroughUrl.new(
              landing_page_id: default_landing_page.id
            )
        )
      ],
      creative_assets: [
        DfareportingUtils::API_NAMESPACE::CreativeAsset.new(
          asset_identifier: html5_asset_id,
          role: 'PRIMARY'
        ),
        DfareportingUtils::API_NAMESPACE::CreativeAsset.new(
          asset_identifier: backup_image_asset_id,
          role: 'BACKUP_IMAGE'
        )
      ],
      name: 'Example HTML5 display creative',
      size: DfareportingUtils::API_NAMESPACE::Size.new(id: size_id),
      type: 'DISPLAY'
    )
  3. 광고 소재를 저장합니다. creatives.insert()을 호출하면 됩니다. 이 광고 소재와 연결할 광고주 ID를 지정해야 합니다.
    # Insert the creative.
    result = service.insert_creative(profile_id, creative)
  4. (선택사항) 광고 소재를 캠페인과 연결합니다. 캠페인 및 광고 소재 ID를 전달하여 campaignCreativeAssociations.insert()을 호출하면 됩니다.
    # Create a new creative-campaign association to insert
    association =
      DfareportingUtils::API_NAMESPACE::CampaignCreativeAssociation.new(
        creative_id: creative_id
      )
    
    # Insert the advertiser group.
    result = service.insert_campaign_creative_association(profile_id, campaign_id,
      association)

광고 만들기

AdCreativePlacement 간의 링크입니다. Ad는 하나 이상의 게재위치에 연결될 수 있으며 하나 이상의 광고 소재를 보유합니다.

명시적 또는 암시적으로 Ad를 만들 수 있습니다.

명시적으로

C#

  1. 이 광고와 연결할 각 광고 소재에 대해 CreativeAssignment 객체를 만듭니다. CreativeAssignment.active 필드를 true로 설정해야 합니다.
    // Create a click-through URL.
    ClickThroughUrl clickThroughUrl = new ClickThroughUrl();
    clickThroughUrl.DefaultLandingPage = true;
    
    // Create a creative assignment.
    CreativeAssignment creativeAssignment = new CreativeAssignment();
    creativeAssignment.Active = true;
    creativeAssignment.CreativeId = creativeId;
    creativeAssignment.ClickThroughUrl = clickThroughUrl;
  2. CreativeAssignment을 저장할 CreativeRotation 객체를 만듭니다. 순환 그룹을 만드는 경우 다른 필수 광고 소재 순환 필드를 설정해야 합니다.
    // Create a creative rotation.
    CreativeRotation creativeRotation = new CreativeRotation();
    creativeRotation.CreativeAssignments = new List<CreativeAssignment>() {
        creativeAssignment
    };
  3. 이 광고가 연결되어야 하는 각 게재위치에 대해 PlacementAssignment 객체를 만듭니다. PlacementAssignment.active 필드를 true로 설정해야 합니다.
    // Create a placement assignment.
    PlacementAssignment placementAssignment = new PlacementAssignment();
    placementAssignment.Active = true;
    placementAssignment.PlacementId = placementId;
  4. Ad객체 만들기 Ad 객체의 creativeRotation 필드에 creativeRotation을 설정하고 Ad 객체의 placementAssignments 배열에 placementAssignments를 설정합니다.
    // Create a delivery schedule.
    DeliverySchedule deliverySchedule = new DeliverySchedule();
    deliverySchedule.ImpressionRatio = 1;
    deliverySchedule.Priority = "AD_PRIORITY_01";
    
    DateTime startDate = DateTime.Now;
    DateTime endDate = Convert.ToDateTime(campaign.EndDate);
    
    // Create a rotation group.
    Ad rotationGroup = new Ad();
    rotationGroup.Active = true;
    rotationGroup.CampaignId = campaignId;
    rotationGroup.CreativeRotation = creativeRotation;
    rotationGroup.DeliverySchedule = deliverySchedule;
    rotationGroup.StartTime = startDate;
    rotationGroup.EndTime = endDate;
    rotationGroup.Name = adName;
    rotationGroup.PlacementAssignments = new List<PlacementAssignment>() {
        placementAssignment
    };
    rotationGroup.Type = "AD_SERVING_STANDARD_AD";
  5. ads.insert()를 호출하여 광고를 저장합니다.
    // Insert the rotation group.
    Ad result = service.Ads.Insert(rotationGroup, profileId).Execute();

자바

  1. 이 광고와 연결할 각 광고 소재에 대해 CreativeAssignment 객체를 만듭니다. CreativeAssignment.active 필드를 true로 설정해야 합니다.
    // Create a click-through URL.
    ClickThroughUrl clickThroughUrl = new ClickThroughUrl();
    clickThroughUrl.setDefaultLandingPage(true);
    
    // Create a creative assignment.
    CreativeAssignment creativeAssignment = new CreativeAssignment();
    creativeAssignment.setActive(true);
    creativeAssignment.setCreativeId(creativeId);
    creativeAssignment.setClickThroughUrl(clickThroughUrl);
  2. CreativeAssignment을 저장할 CreativeRotation 객체를 만듭니다. 순환 그룹을 만드는 경우 다른 필수 광고 소재 순환 필드를 설정해야 합니다.
    // Create a creative rotation.
    CreativeRotation creativeRotation = new CreativeRotation();
    creativeRotation.setCreativeAssignments(ImmutableList.of(creativeAssignment));
  3. 이 광고가 연결되어야 하는 각 게재위치에 대해 PlacementAssignment 객체를 만듭니다. PlacementAssignment.active 필드를 true로 설정해야 합니다.
    // Create a placement assignment.
    PlacementAssignment placementAssignment = new PlacementAssignment();
    placementAssignment.setActive(true);
    placementAssignment.setPlacementId(placementId);
  4. Ad객체 만들기 Ad 객체의 creativeRotation 필드에 creativeRotation을 설정하고 Ad 객체의 placementAssignments 배열에 placementAssignments를 설정합니다.
    // Create a delivery schedule.
    DeliverySchedule deliverySchedule = new DeliverySchedule();
    deliverySchedule.setImpressionRatio(1L);
    deliverySchedule.setPriority("AD_PRIORITY_01");
    
    DateTime startDate = new DateTime(new Date());
    DateTime endDate = new DateTime(campaign.getEndDate().getValue());
    
    // Create a rotation group.
    Ad rotationGroup = new Ad();
    rotationGroup.setActive(true);
    rotationGroup.setCampaignId(campaignId);
    rotationGroup.setCreativeRotation(creativeRotation);
    rotationGroup.setDeliverySchedule(deliverySchedule);
    rotationGroup.setStartTime(startDate);
    rotationGroup.setEndTime(endDate);
    rotationGroup.setName(adName);
    rotationGroup.setPlacementAssignments(ImmutableList.of(placementAssignment));
    rotationGroup.setType("AD_SERVING_STANDARD_AD");
  5. ads.insert()를 호출하여 광고를 저장합니다.
    // Insert the rotation group.
    Ad result = reporting.ads().insert(profileId, rotationGroup).execute();

PHP

  1. 이 광고와 연결할 각 광고 소재에 대해 CreativeAssignment 객체를 만듭니다. CreativeAssignment.active 필드를 true로 설정해야 합니다.
    // Create a click-through URL.
    $url = new Google_Service_Dfareporting_ClickThroughUrl();
    $url->setDefaultLandingPage(true);
    
    // Create a creative assignment.
    $creativeAssignment =
        new Google_Service_Dfareporting_CreativeAssignment();
    $creativeAssignment->setActive(true);
    $creativeAssignment->setCreativeId($values['creative_id']);
    $creativeAssignment->setClickThroughUrl($url);
  2. CreativeAssignment을 저장할 CreativeRotation 객체를 만듭니다. 순환 그룹을 만드는 경우 다른 필수 광고 소재 순환 필드를 설정해야 합니다.
    // Create a creative rotation.
    $creativeRotation = new Google_Service_Dfareporting_CreativeRotation();
    $creativeRotation->setCreativeAssignments([$creativeAssignment]);
  3. 이 광고가 연결되어야 하는 각 게재위치에 대해 PlacementAssignment 객체를 만듭니다. PlacementAssignment.active 필드를 true로 설정해야 합니다.
    // Create a placement assignment.
    $placementAssignment =
        new Google_Service_Dfareporting_PlacementAssignment();
    $placementAssignment->setActive(true);
    $placementAssignment->setPlacementId($values['placement_id']);
  4. Ad객체 만들기 Ad 객체의 creativeRotation 필드에 creativeRotation을 설정하고 Ad 객체의 placementAssignments 배열에 placementAssignments를 설정합니다.
    // Create a delivery schedule.
    $deliverySchedule = new Google_Service_Dfareporting_DeliverySchedule();
    $deliverySchedule->setImpressionRatio(1);
    $deliverySchedule->SetPriority('AD_PRIORITY_01');
    
    $startDate = new DateTime('today');
    $endDate = new DateTime($campaign->getEndDate());
    
    // Create a rotation group.
    $ad = new Google_Service_Dfareporting_Ad();
    $ad->setActive(true);
    $ad->setCampaignId($values['campaign_id']);
    $ad->setCreativeRotation($creativeRotation);
    $ad->setDeliverySchedule($deliverySchedule);
    $ad->setStartTime($startDate->format('Y-m-d') . 'T23:59:59Z');
    $ad->setEndTime($endDate->format('Y-m-d') . 'T00:00:00Z');
    $ad->setName($values['ad_name']);
    $ad->setPlacementAssignments([$placementAssignment]);
    $ad->setType('AD_SERVING_STANDARD_AD');
  5. ads.insert()를 호출하여 광고를 저장합니다.
    $result = $this->service->ads->insert($values['user_profile_id'], $ad);

Python

  1. 이 광고와 연결할 각 광고 소재에 대해 CreativeAssignment 객체를 만듭니다. CreativeAssignment.active 필드를 true로 설정해야 합니다.
    # Construct creative assignment.
    creative_assignment = {
        'active': 'true',
        'creativeId': creative_id,
        'clickThroughUrl': {
            'defaultLandingPage': 'true'
        }
    }
  2. CreativeAssignment을 저장할 CreativeRotation 객체를 만듭니다. 순환 그룹을 만드는 경우 다른 필수 광고 소재 순환 필드를 설정해야 합니다.
    # Construct creative rotation.
    creative_rotation = {
        'creativeAssignments': [creative_assignment],
        'type': 'CREATIVE_ROTATION_TYPE_RANDOM',
        'weightCalculationStrategy': 'WEIGHT_STRATEGY_OPTIMIZED'
    }
  3. 이 광고가 연결되어야 하는 각 게재위치에 대해 PlacementAssignment 객체를 만듭니다. PlacementAssignment.active 필드를 true로 설정해야 합니다.
    # Construct placement assignment.
    placement_assignment = {
        'active': 'true',
        'placementId': placement_id,
    }
  4. Ad객체 만들기 Ad 객체의 creativeRotation 필드에 creativeRotation을 설정하고 Ad 객체의 placementAssignments 배열에 placementAssignments를 설정합니다.
    # Construct delivery schedule.
    delivery_schedule = {
        'impressionRatio': '1',
        'priority': 'AD_PRIORITY_01'
    }
    
    # Construct and save ad.
    ad = {
        'active': 'true',
        'campaignId': campaign_id,
        'creativeRotation': creative_rotation,
        'deliverySchedule': delivery_schedule,
        'endTime': '%sT00:00:00Z' % campaign['endDate'],
        'name': 'Test Rotation Group',
        'placementAssignments': [placement_assignment],
        'startTime': '%sT23:59:59Z' % time.strftime('%Y-%m-%d'),
        'type': 'AD_SERVING_STANDARD_AD'
    }
  5. ads.insert()를 호출하여 광고를 저장합니다.
    request = service.ads().insert(profileId=profile_id, body=ad)
    
    # Execute request and print response.
    response = request.execute()

Ruby

  1. 이 광고와 연결할 각 광고 소재에 대해 CreativeAssignment 객체를 만듭니다. CreativeAssignment.active 필드를 true로 설정해야 합니다.
    # Construct creative assignment.
    creative_assignment =
      DfareportingUtils::API_NAMESPACE::CreativeAssignment.new(
        active: true,
        creative_id: creative_id,
        click_through_url: DfareportingUtils::API_NAMESPACE::ClickThroughUrl.new(
          default_landing_page: true
        )
      )
  2. CreativeAssignment을 저장할 CreativeRotation 객체를 만듭니다. 순환 그룹을 만드는 경우 다른 필수 광고 소재 순환 필드를 설정해야 합니다.
    # Construct creative rotation.
    creative_rotation = DfareportingUtils::API_NAMESPACE::CreativeRotation.new(
      creative_assignments: [creative_assignment],
      type: 'CREATIVE_ROTATION_TYPE_RANDOM',
      weight_calculation_strategy: 'WEIGHT_STRATEGY_OPTIMIZED'
    )
  3. 이 광고가 연결되어야 하는 각 게재위치에 대해 PlacementAssignment 객체를 만듭니다. PlacementAssignment.active 필드를 true로 설정해야 합니다.
    # Construct placement assignment.
    placement_assignment =
      DfareportingUtils::API_NAMESPACE::PlacementAssignment.new(
        active: true,
        placement_id: placement_id
      )
  4. Ad객체 만들기 Ad 객체의 creativeRotation 필드에 creativeRotation을 설정하고 Ad 객체의 placementAssignments 배열에 placementAssignments를 설정합니다.
    # Construct delivery schedule.
    delivery_schedule = DfareportingUtils::API_NAMESPACE::DeliverySchedule.new(
      impression_ratio: 1,
      priority: 'AD_PRIORITY_01'
    )
    
    # Construct and save ad.
    ad = DfareportingUtils::API_NAMESPACE::Ad.new(
      active: true,
      campaign_id: campaign_id,
      creative_rotation: creative_rotation,
      delivery_schedule: delivery_schedule,
      end_time: format('%sT00:00:00Z', campaign.end_date),
      name: 'Example Rotation Group',
      placement_assignments: [placement_assignment],
      start_time: format('%sT23:59:59Z', Time.now.strftime('%Y-%m-%d')),
      type: 'AD_SERVING_STANDARD_AD'
    )
  5. ads.insert()를 호출하여 광고를 저장합니다.
    result = service.insert_ad(profile_id, ad)

암시적으로

C#

  1. Placement를 만들고 저장합니다.
  2. Creative를 만들고 저장합니다.
  3. campaignCreativeAssociations.insert()을 호출하여 CreativePlacement에 사용된 것과 동일한 Campaign와 연결합니다 (광고 소재 만들기 섹션의 4단계 참고). 이렇게 하면 광고 소재와 게재위치 모두에 연결된 기본 광고가 생성됩니다.
    // Create the campaign creative association structure.
    CampaignCreativeAssociation association = new CampaignCreativeAssociation();
    association.CreativeId = creativeId;
    
    // Insert the association.
    CampaignCreativeAssociation result =
        service.CampaignCreativeAssociations.Insert(association, profileId, campaignId).Execute();

자바

  1. Placement를 만들고 저장합니다.
  2. Creative를 만들고 저장합니다.
  3. campaignCreativeAssociations.insert()을 호출하여 CreativePlacement에 사용된 것과 동일한 Campaign와 연결합니다 (광고 소재 만들기 섹션의 4단계 참고). 이렇게 하면 광고 소재와 게재위치 모두에 연결된 기본 광고가 생성됩니다.
    // Create the campaign creative association structure.
    CampaignCreativeAssociation association = new CampaignCreativeAssociation();
    association.setCreativeId(creativeId);
    
    // Insert the association.
    CampaignCreativeAssociation result = reporting
        .campaignCreativeAssociations().insert(profileId, campaignId, association)
        .execute();

PHP

  1. Placement를 만들고 저장합니다.
  2. Creative를 만들고 저장합니다.
  3. campaignCreativeAssociations.insert()을 호출하여 CreativePlacement에 사용된 것과 동일한 Campaign와 연결합니다 (광고 소재 만들기 섹션의 4단계 참고). 이렇게 하면 광고 소재와 게재위치 모두에 연결된 기본 광고가 생성됩니다.
    $association =
        new Google_Service_Dfareporting_CampaignCreativeAssociation();
    $association->setCreativeId($values['creative_id']);
    
    $result = $this->service->campaignCreativeAssociations->insert(
        $values['user_profile_id'],
        $values['campaign_id'],
        $association
    );

Python

  1. Placement를 만들고 저장합니다.
  2. Creative를 만들고 저장합니다.
  3. campaignCreativeAssociations.insert()을 호출하여 CreativePlacement에 사용된 것과 동일한 Campaign와 연결합니다 (광고 소재 만들기 섹션의 4단계 참고). 이렇게 하면 광고 소재와 게재위치 모두에 연결된 기본 광고가 생성됩니다.
    # Construct the request.
    association = {
        'creativeId': creative_id
    }
    
    request = service.campaignCreativeAssociations().insert(
        profileId=profile_id, campaignId=campaign_id, body=association)
    
    # Execute request and print response.
    response = request.execute()

Ruby

  1. Placement를 만들고 저장합니다.
  2. Creative를 만들고 저장합니다.
  3. campaignCreativeAssociations.insert()을 호출하여 CreativePlacement에 사용된 것과 동일한 Campaign와 연결합니다 (광고 소재 만들기 섹션의 4단계 참고). 이렇게 하면 광고 소재와 게재위치 모두에 연결된 기본 광고가 생성됩니다.
    # Create a new creative-campaign association to insert
    association =
      DfareportingUtils::API_NAMESPACE::CampaignCreativeAssociation.new(
        creative_id: creative_id
      )
    
    # Insert the advertiser group.
    result = service.insert_campaign_creative_association(profile_id, campaign_id,
      association)

광고를 만들면 Ad를 만드는 추가 단계를 거치지 않아도 됩니다. 캠페인 내에 지정된 크기의 기본 광고가 아직 없는 경우에만 이 작업을 실행할 수 있습니다.

객체 검색

찾을 객체를 정의하는 서비스에서 노출하는 list() 작업을 호출하여 객체를 검색하고 해당 객체 유형에 적합한 선택적 기준을 지정할 수 있습니다. 예를 들어 광고 객체를 검색하려면 ads.list()를 호출합니다. 선택적 기준은 해당 객체에 적합한 속성 집합을 노출합니다. 검색할 속성을 원하는 만큼 입력합니다. 검색에서는 기준을 모두 충족하는 객체만 반환되며, 기준 중 하나라도 일치하는 객체를 검색할 수는 없습니다. 문자열은 * 와일드 카드를 지원하며, 대소문자를 구분하지 않고 더 큰 문자열 내에서 일치합니다.

성능을 개선하기 위해 fields 매개변수를 사용하여 부분 응답을 요청할 수 있습니다. 이렇게 하면 서버에서 전체 리소스 표현이 아닌 지정된 필드만 반환합니다. 이 주제에 관한 자세한 내용은 성능 팁 가이드를 참고하세요.

Paging

list() 요청의 결과를 모두 가져오는 것이 바람직하지 않은 경우도 있습니다. 예를 들어 수천 개의 광고 중에서 가장 최신 광고 10개만 관심이 있을 수 있습니다. 이를 위해 많은 list() 메서드를 사용하면 페이징이라는 프로세스를 통해 더 적은 결과를 요청할 수 있습니다.

페이징을 지원하는 메서드는 페이지라는 그룹으로 결과의 하위 집합을 반환합니다. 페이지당 최대 결과 수는 1,000개 (기본값)입니다. maxResults를 설정하여 페이지당 결과 수를 변경할 수 있으며, 응답에서 반환된 nextPageToken를 사용하여 페이지를 반복할 수 있습니다.

C#

// Limit the fields returned.
String fields = "nextPageToken,ads(advertiserId,id,name)";

AdsListResponse result;
String nextPageToken = null;

do {
  // Create and execute the ad list request.
  AdsResource.ListRequest request = service.Ads.List(profileId);
  request.Active = true;
  request.Fields = fields;
  request.PageToken = nextPageToken;
  result = request.Execute();

  foreach (Ad ad in result.Ads) {
    Console.WriteLine(
        "Ad with ID {0} and name \"{1}\" is associated with advertiser" +
        " ID {2}.", ad.Id, ad.Name, ad.AdvertiserId);
  }

  // Update the next page token.
  nextPageToken = result.NextPageToken;
} while (result.Ads.Any() && !String.IsNullOrEmpty(nextPageToken));

자바

// Limit the fields returned.
String fields = "nextPageToken,ads(advertiserId,id,name)";

AdsListResponse result;
String nextPageToken = null;

do {
  // Create and execute the ad list request.
  result = reporting.ads().list(profileId).setActive(true).setFields(fields)
      .setPageToken(nextPageToken).execute();

  for (Ad ad : result.getAds()) {
    System.out.printf(
        "Ad with ID %d and name \"%s\" is associated with advertiser ID %d.%n", ad.getId(),
        ad.getName(), ad.getAdvertiserId());
  }

  // Update the next page token.
  nextPageToken = result.getNextPageToken();
} while (!result.getAds().isEmpty() && !Strings.isNullOrEmpty(nextPageToken));

PHP

$response = null;
$pageToken = null;

do {
    // Create and execute the ads list request.
    $response = $this->service->ads->listAds(
        $values['user_profile_id'],
        ['active' => true, 'pageToken' => $pageToken]
    );

    foreach ($response->getAds() as $ads) {
        $this->printResultsTableRow($ads);
    }

    // Update the next page token.
    $pageToken = $response->getNextPageToken();
} while (!empty($response->getAds()) && !empty($pageToken));

Python

# Construct the request.
request = service.ads().list(profileId=profile_id, active=True)

while True:
  # Execute request and print response.
  response = request.execute()

  for ad in response['ads']:
    print 'Found ad with ID %s and name "%s".' % (ad['id'], ad['name'])

  if response['ads'] and response['nextPageToken']:
    request = service.ads().list_next(request, response)
  else:
    break

Ruby

token = nil
loop do
  result = service.list_ads(profile_id,
    page_token: token,
    fields: 'nextPageToken,ads(id,name)')

  # Display results.
  if result.ads.any?
    result.ads.each do |ad|
      puts format('Found ad with ID %d and name "%s".', ad.id, ad.name)
    end

    token = result.next_page_token
  else
    # Stop paging if there are no more results.
    token = nil
  end

  break if token.to_s.empty?
end

플러드라이트 태그 생성

플러드라이트 태그는 페이지에 삽입된 HTML 태그로, 사이트 내에서 사용자 액션 (예: 구매)을 추적하는 데 사용됩니다. 플러드라이트 태그를 생성하려면 FloodlightActivityGroup에 속한 FloodlightActivity가 필요합니다.

C#

  1. name, type, floodlightConfigurationId 값을 전달하여 새 플러드라이트 액티비티 그룹을 만듭니다.
    // Create the floodlight activity group.
    FloodlightActivityGroup floodlightActivityGroup = new FloodlightActivityGroup();
    floodlightActivityGroup.Name = groupName;
    floodlightActivityGroup.FloodlightConfigurationId = floodlightConfigurationId;
    floodlightActivityGroup.Type = "COUNTER";
  2. 새 그룹의 ID를 반환하는 floodlightActivityGroups.insert()를 호출하여 플러드라이트 활동 그룹을 저장합니다.
    // Insert the activity group.
    FloodlightActivityGroup result =
        service.FloodlightActivityGroups.Insert(floodlightActivityGroup, profileId).Execute();
  3. 새 플러드라이트 활동을 만들고, 방금 만든 플러드라이트 활동 그룹의 ID와 기타 필수 입력란을 모두 할당합니다.
    // Set floodlight activity structure.
    FloodlightActivity activity = new FloodlightActivity();
    activity.CountingMethod = "STANDARD_COUNTING";
    activity.Name = activityName;
    activity.FloodlightActivityGroupId = activityGroupId;
    activity.FloodlightTagType = "GLOBAL_SITE_TAG";
    activity.ExpectedUrl = url;
  4. 새 활동의 ID를 반환하는 floodlightActivities.insert()를 호출하여 새 활동을 저장합니다.
    // Create the floodlight tag activity.
    FloodlightActivity result =
        service.FloodlightActivities.Insert(activity, profileId).Execute();
  5. 새 활동의 floodlightActivityIdfloodlightActivities.generatetag()를 호출하여 태그를 생성합니다. 광고주 웹사이트의 웹마스터에게 태그를 보냅니다.
    // Generate the floodlight activity tag.
    FloodlightActivitiesResource.GeneratetagRequest request =
        service.FloodlightActivities.Generatetag(profileId);
    request.FloodlightActivityId = activityId;
    
    FloodlightActivitiesGenerateTagResponse response = request.Execute();

자바

  1. name, type, floodlightConfigurationId 값을 전달하여 새 플러드라이트 액티비티 그룹을 만듭니다.
    // Create the floodlight activity group.
    FloodlightActivityGroup floodlightActivityGroup = new FloodlightActivityGroup();
    floodlightActivityGroup.setName(groupName);
    floodlightActivityGroup.setFloodlightConfigurationId(floodlightConfigurationId);
    floodlightActivityGroup.setType("COUNTER");
  2. 새 그룹의 ID를 반환하는 floodlightActivityGroups.insert()를 호출하여 플러드라이트 활동 그룹을 저장합니다.
    // Insert the activity group.
    FloodlightActivityGroup result =
        reporting.floodlightActivityGroups().insert(profileId, floodlightActivityGroup).execute();
  3. 새 플러드라이트 활동을 만들고, 방금 만든 플러드라이트 활동 그룹의 ID와 기타 필수 입력란을 모두 할당합니다.
    // Set floodlight activity structure.
    FloodlightActivity activity = new FloodlightActivity();
    activity.setName(activityName);
    activity.setCountingMethod("STANDARD_COUNTING");
    activity.setExpectedUrl(url);
    activity.setFloodlightActivityGroupId(activityGroupId);
    activity.setFloodlightTagType("GLOBAL_SITE_TAG");
  4. 새 활동의 ID를 반환하는 floodlightActivities.insert()를 호출하여 새 활동을 저장합니다.
    // Create the floodlight tag activity.
    FloodlightActivity result =
        reporting.floodlightActivities().insert(profileId, activity).execute();
  5. 새 활동의 floodlightActivityIdfloodlightActivities.generatetag()를 호출하여 태그를 생성합니다. 광고주 웹사이트의 웹마스터에게 태그를 보냅니다.
    // Generate the floodlight activity tag.
    Generatetag request = reporting.floodlightActivities().generatetag(profileId);
    request.setFloodlightActivityId(activityId);
    
    FloodlightActivitiesGenerateTagResponse response = request.execute();

PHP

  1. name, type, floodlightConfigurationId 값을 전달하여 새 플러드라이트 액티비티 그룹을 만듭니다.
    $group = new Google_Service_Dfareporting_FloodlightActivityGroup();
    $group->setFloodlightConfigurationId($values['configuration_id']);
    $group->setName($values['group_name']);
    $group->setType('COUNTER');
  2. 새 그룹의 ID를 반환하는 floodlightActivityGroups.insert()를 호출하여 플러드라이트 활동 그룹을 저장합니다.
    $result = $this->service->floodlightActivityGroups->insert(
        $values['user_profile_id'],
        $group
    );
  3. 새 플러드라이트 활동을 만들고, 방금 만든 플러드라이트 활동 그룹의 ID와 기타 필수 입력란을 모두 할당합니다.
    $activity = new Google_Service_Dfareporting_FloodlightActivity();
    $activity->setCountingMethod('STANDARD_COUNTING');
    $activity->setExpectedUrl($values['url']);
    $activity->setFloodlightActivityGroupId($values['activity_group_id']);
    $activity->setFloodlightTagType('GLOBAL_SITE_TAG');
    $activity->setName($values['activity_name']);
  4. 새 활동의 ID를 반환하는 floodlightActivities.insert()를 호출하여 새 활동을 저장합니다.
    $result = $this->service->floodlightActivities->insert(
        $values['user_profile_id'],
        $activity
    );
  5. 새 활동의 floodlightActivityIdfloodlightActivities.generatetag()를 호출하여 태그를 생성합니다. 광고주 웹사이트의 웹마스터에게 태그를 보냅니다.
    $result = $this->service->floodlightActivities->generatetag(
        $values['user_profile_id'],
        ['floodlightActivityId' => $values['activity_id']]
    );

Python

  1. name, type, floodlightConfigurationId 값을 전달하여 새 플러드라이트 액티비티 그룹을 만듭니다.
    # Construct and save floodlight activity group.
    activity_group = {
        'name': 'Test Floodlight Activity Group',
        'floodlightConfigurationId': floodlight_config_id,
        'type': 'COUNTER'
    }
  2. 새 그룹의 ID를 반환하는 floodlightActivityGroups.insert()를 호출하여 플러드라이트 활동 그룹을 저장합니다.
    request = service.floodlightActivityGroups().insert(
        profileId=profile_id, body=activity_group)
  3. 새 플러드라이트 활동을 만들고, 방금 만든 플러드라이트 활동 그룹의 ID와 기타 필수 입력란을 모두 할당합니다.
    # Construct and save floodlight activity.
    floodlight_activity = {
        'countingMethod': 'STANDARD_COUNTING',
        'expectedUrl': 'http://www.google.com',
        'floodlightActivityGroupId': activity_group_id,
        'floodlightTagType': 'GLOBAL_SITE_TAG',
        'name': 'Test Floodlight Activity'
    }
  4. 새 활동의 ID를 반환하는 floodlightActivities.insert()를 호출하여 새 활동을 저장합니다.
    request = service.floodlightActivities().insert(
        profileId=profile_id, body=floodlight_activity)
  5. 새 활동의 floodlightActivityIdfloodlightActivities.generatetag()를 호출하여 태그를 생성합니다. 광고주 웹사이트의 웹마스터에게 태그를 보냅니다.
    # Construct the request.
    request = service.floodlightActivities().generatetag(
        profileId=profile_id, floodlightActivityId=activity_id)
    
    # Execute request and print response.
    response = request.execute()

Ruby

  1. name, type, floodlightConfigurationId 값을 전달하여 새 플러드라이트 액티비티 그룹을 만듭니다.
    # Create a new floodlight activity group resource to insert.
    activity_group =
      DfareportingUtils::API_NAMESPACE::FloodlightActivityGroup.new(
        floodlight_configuration_id: floodlight_config_id,
        name:
          format('Example Floodlight Activity Group #%s', SecureRandom.hex(3)),
        type: 'COUNTER'
      )
  2. 새 그룹의 ID를 반환하는 floodlightActivityGroups.insert()를 호출하여 플러드라이트 활동 그룹을 저장합니다.
    # Insert the floodlight activity group.
    result = service.insert_floodlight_activity_group(profile_id, activity_group)
  3. 새 플러드라이트 활동을 만들고, 방금 만든 플러드라이트 활동 그룹의 ID와 기타 필수 입력란을 모두 할당합니다.
    # Create a new floodlight activity resource to insert.
    activity = DfareportingUtils::API_NAMESPACE::FloodlightActivity.new(
      counting_method: 'STANDARD_COUNTING',
      expected_url: 'http://www.google.com',
      floodlight_activity_group_id: activity_group_id,
      floodlight_tag_type: 'GLOBAL_SITE_TAG',
      name: format('Example Floodlight Activity #%s', SecureRandom.hex(3))
    )
  4. 새 활동의 ID를 반환하는 floodlightActivities.insert()를 호출하여 새 활동을 저장합니다.
    # Insert the floodlight activity.
    result = service.insert_floodlight_activity(profile_id, activity)
  5. 새 활동의 floodlightActivityIdfloodlightActivities.generatetag()를 호출하여 태그를 생성합니다. 광고주 웹사이트의 웹마스터에게 태그를 보냅니다.
    # Construct the request.
    result = service.generatetag_floodlight_activity(profile_id,
      floodlight_activity_id: activity_id)

게재위치 태그 생성

마지막 단계는 광고를 게재하기 위해 게시자에게 전송할 HTML 태그를 생성하는 것입니다. API를 통해 태그를 생성하려면 placements.generatetags()에 요청을 보내 placementIdstagFormats 집합을 지정합니다.

C#

// Generate the placement activity tags.
PlacementsResource.GeneratetagsRequest request =
    service.Placements.Generatetags(profileId);
request.CampaignId = campaignId;
request.TagFormats =
    PlacementsResource.GeneratetagsRequest.TagFormatsEnum.PLACEMENTTAGIFRAMEJAVASCRIPT;
request.PlacementIds = placementId.ToString();

PlacementsGenerateTagsResponse response = request.Execute();

자바

// Generate the placement activity tags.
Generatetags request = reporting.placements().generatetags(profileId);
request.setCampaignId(campaignId);
request.setTagFormats(tagFormats);
request.setPlacementIds(ImmutableList.of(placementId));

PlacementsGenerateTagsResponse response = request.execute();

PHP

$placementTags = $this->service->placements->generatetags(
    $values['user_profile_id'],
    ['campaignId' => $values['campaign_id'],
     'placementIds' => [$values['placement_id']],
     'tagFormats' => ['PLACEMENT_TAG_STANDARD',
                      'PLACEMENT_TAG_IFRAME_JAVASCRIPT',
                      'PLACEMENT_TAG_INTERNAL_REDIRECT']
    ]
);

Python

# Construct the request.
request = service.placements().generatetags(
    profileId=profile_id, campaignId=campaign_id,
    placementIds=[placement_id])

# Execute request and print response.
response = request.execute()

Ruby

# Construct the request.
result = service.generate_placement_tags(profile_id,
  campaign_id: campaign_id,
  placement_ids: [placement_id])