อัปโหลด Conversion

คู่มือนี้มีวิธีการโดยละเอียดสำหรับการอัปโหลด Conversion ออฟไลน์ โดยใช้บริการ Conversions ของ Campaign Manager 360 API ก่อนดำเนินการต่อ เราขอแนะนำให้คุณอ่านภาพรวมเพื่อทำความเข้าใจเกี่ยวกับ Conversion ออฟไลน์และทำความคุ้นเคยกับแนวคิดที่กล่าวถึงในคู่มือนี้

กำหนดค่าแหล่งข้อมูล Conversion

ขั้นตอนแรกในกระบวนการอัปโหลด Conversion คือการสร้างออบเจ็กต์ทรัพยากร Conversionอย่างน้อย 1 รายการ ออบเจ็กต์แต่ละรายการ แสดงเหตุการณ์ Conversion รายการเดียวและมีฟิลด์ที่จำเป็น 2-3 รายการ ดังนี้

ช่อง คำอธิบาย
floodlightActivityId กิจกรรม Floodlight ที่จะเชื่อมโยงกับ Conversion นี้
floodlightConfigurationId การกำหนดค่า Floodlight ที่กิจกรรมที่ระบุใช้
ordinal ค่าที่ใช้ควบคุมวิธีที่ระบบกรองข้อมูล Conversion จากอุปกรณ์หรือผู้ใช้รายเดียวกันในวันเดียวกันออก ดูข้อมูลเพิ่มเติมได้ที่คำถามที่พบบ่อย
timestampMicros การประทับเวลาของการแปลงในหน่วยไมโครวินาทีตั้งแต่ Epoch ของ Unix

นอกจากนี้ ออบเจ็กต์แต่ละรายการต้องมีฟิลด์ใดฟิลด์หนึ่งต่อไปนี้

ช่อง คำอธิบาย
encryptedUserId รหัสผู้ใช้ที่เข้ารหัสรายการเดียวซึ่งได้จากมาโครการจับคู่%m หรือการโอนข้อมูล
encryptedUserIdCandidates[] รายการรหัสผู้ใช้ที่เข้ารหัสซึ่งได้จากมาโครการจับคู่%m หรือการโอนข้อมูล ระบบจะใช้รหัสแรกที่มีการแสดง Floodlight ที่บันทึกไว้ก่อน timestampMicros ที่ระบุ หากไม่มีรหัสใดตรงกับการเปิดเผยที่มีอยู่ ระบบจะแสดงข้อผิดพลาด
dclid ตัวระบุคลิกใน Display ที่สร้างขึ้นโดย Campaign Manager 360 หรือ Display & Video 360
gclid หมายเลขระบุคลิกของ Google ที่สร้างขึ้นโดย Google Ads หรือ Search Ads 360
matchId ตัวระบุที่ไม่ซ้ำกันซึ่งผู้ลงโฆษณาสร้างขึ้นที่ส่งไปยัง Campaign Manager 360 ผ่านแท็ก Floodlight
mobileDeviceId รหัสมือถือที่ไม่มีการเข้ารหัสในรูปแบบ IDFA หรือ AdID หรือตัวระบุสําหรับการโฆษณา (IFA) บนทีวีที่เชื่อมต่ออินเทอร์เน็ตจากแพลตฟอร์มอุปกรณ์ CTV ที่รองรับ (Roku, Fire TV, Android TV, Apple TV, Xbox, Samsung, Vizio) โปรดทราบว่า Google ไม่รองรับ IFA บนทีวีที่เชื่อมต่ออินเทอร์เน็ตที่รองรับ YouTube

สุดท้าย Conversion แต่ละรายการมีเมตริก 2 รายการ ได้แก่

ช่อง คำอธิบาย
quantity ต้องระบุ จำนวนสินค้าที่เชื่อมโยงกับ Conversion ต้องมีค่าอย่างน้อย 1 เพื่อให้ระบบนับ Conversion รวมในเมตริกบางอย่าง (เช่น Conversion ทั้งหมด)
value จํานวนเงินดอลลาร์ที่เชื่อมโยงกับ Conversion ซึ่งตีความตามสกุลเงินของผู้ลงโฆษณาที่เป็นเจ้าของการกำหนดค่า Floodlight

ช่องที่ไม่บังคับจะระบุไว้ในเอกสารอ้างอิง

ตัวอย่างด้านล่างแสดงการสร้างออบเจ็กต์ทรัพยากร Conversion อย่างง่าย

C#

// Generate a timestamp in milliseconds since Unix epoch.
TimeSpan timeSpan = DateTime.UtcNow - new DateTime(1970, 1, 1);
long currentTimeInMilliseconds = (long) timeSpan.TotalMilliseconds;

// Find the Floodlight configuration ID based on the provided activity ID.
FloodlightActivity floodlightActivity =
    service.FloodlightActivities.Get(profileId, floodlightActivityId).Execute();
long floodlightConfigurationId = (long) floodlightActivity.FloodlightConfigurationId;

// Create the conversion.
Conversion conversion = new Conversion();
conversion.EncryptedUserId = conversionUserId;
conversion.FloodlightActivityId = floodlightActivityId;
conversion.FloodlightConfigurationId = floodlightConfigurationId;
conversion.Ordinal = currentTimeInMilliseconds.ToString();
conversion.TimestampMicros = currentTimeInMilliseconds * 1000;

Java

long currentTimeInMilliseconds = System.currentTimeMillis();

// Find Floodlight configuration ID based on the provided activity ID.
FloodlightActivity floodlightActivity = reporting.floodlightActivities()
    .get(profileId, floodlightActivityId).execute();
long floodlightConfigurationId = floodlightActivity.getFloodlightConfigurationId();

Conversion conversion = new Conversion();
conversion.setEncryptedUserId(encryptedUserId);
conversion.setFloodlightActivityId(floodlightActivityId);
conversion.setFloodlightConfigurationId(floodlightConfigurationId);
conversion.setOrdinal(String.valueOf(currentTimeInMilliseconds));
conversion.setTimestampMicros(currentTimeInMilliseconds * 1000);

PHP

$currentTimeInMicros = time() * 1000 * 1000;

// Find Floodlight configuration ID based on provided activity ID.
$activity = $this->service->floodlightActivities->get(
    $values['user_profile_id'],
    $values['floodlight_activity_id']
);
$floodlightConfigId = $activity->getFloodlightConfigurationId();

$conversion = new Google_Service_Dfareporting_Conversion();
$conversion->setEncryptedUserId($values['encrypted_user_id']);
$conversion->setFloodlightActivityId($values['floodlight_activity_id']);
$conversion->setFloodlightConfigurationId($floodlightConfigId);
$conversion->setOrdinal($currentTimeInMicros);
$conversion->setTimestampMicros($currentTimeInMicros);

Python

# Look up the Floodlight configuration ID based on activity ID.
floodlight_activity = service.floodlightActivities().get(
    profileId=profile_id, id=floodlight_activity_id).execute()
floodlight_config_id = floodlight_activity['floodlightConfigurationId']

current_time_in_micros = int(time.time() * 1000000)

# Construct the conversion.
conversion = {
    'encryptedUserId': encrypted_user_id,
    'floodlightActivityId': floodlight_activity_id,
    'floodlightConfigurationId': floodlight_config_id,
    'ordinal': current_time_in_micros,
    'timestampMicros': current_time_in_micros
}

Ruby

# Look up the Floodlight configuration ID based on activity ID.
floodlight_activity = service.get_floodlight_activity(profile_id,
  floodlight_activity_id)
floodlight_config_id = floodlight_activity.floodlight_configuration_id

current_time_in_micros = DateTime.now.strftime('%Q').to_i * 1000

# Construct the conversion.
conversion = DfareportingUtils::API_NAMESPACE::Conversion.new(
  encrypted_user_id: encrypted_user_id,
  floodlight_activity_id: floodlight_activity_id,
  floodlight_configuration_id: floodlight_config_id,
  ordinal: current_time_in_micros,
  timestamp_micros: current_time_in_micros
)

ระบุข้อมูลการเข้ารหัส

หากคุณวางแผนที่จะระบุแหล่งที่มาของ Conversion ออฟไลน์เป็นรหัสผู้ใช้ที่เข้ารหัส ดังใน ตัวอย่างก่อนหน้า คุณจะต้องระบุรายละเอียดบางอย่างเกี่ยวกับวิธีการเข้ารหัส เป็นส่วนหนึ่งของคำขอแทรก โดยเฉพาะอย่างยิ่ง คุณจะต้องทราบข้อมูลต่อไปนี้

  1. แหล่งที่มาของการเข้ารหัส ซึ่งอธิบายว่ารหัสที่เข้ารหัสเป็นกลุ่ม มาจากที่ใด ค่าที่ยอมรับได้คือ AD_SERVING สำหรับรหัสที่มาจากมาโคร %m match หรือ DATA_TRANSFER สำหรับรหัสที่มาจากไฟล์การโอนข้อมูล

  2. เอนทิตีการเข้ารหัส ซึ่งเป็นชุดค่าที่ไม่ซ้ำกันที่ใช้เพื่อเข้ารหัส รหัสผู้ใช้ โดยปกติแล้ว ค่าเหล่านี้จะเกี่ยวข้องกับบัญชี Campaign Manager 360 เมื่อแหล่งที่มาคือการโอนข้อมูล หรือผู้ลงโฆษณา Campaign Manager 360 เมื่อแหล่งที่มาคือมาโคร %m แต่ก็ไม่ได้เป็นเช่นนี้เสมอไป หากไม่แน่ใจ โปรดติดต่อตัวแทนบัญชี Campaign Manager 360 หรือทีมสนับสนุนของ Campaign Manager 360 เพื่อขอข้อมูลเพิ่มเติม

หากจำเป็น การสร้างออบเจ็กต์ EncryptionInfo ที่ระบุค่า เหล่านี้เป็นขั้นตอนที่ 2 ในกระบวนการอัปโหลด Conversion

C#

// Create the encryption info.
EncryptionInfo encryptionInfo = new EncryptionInfo();
encryptionInfo.EncryptionEntityId = encryptionEntityId;
encryptionInfo.EncryptionEntityType = encryptionEntityType;
encryptionInfo.EncryptionSource = encryptionSource;

Java

// Create the encryption info.
EncryptionInfo encryptionInfo = new EncryptionInfo();
encryptionInfo.setEncryptionEntityId(encryptionEntityId);
encryptionInfo.setEncryptionEntityType(encryptionEntityType);
encryptionInfo.setEncryptionSource(encryptionSource);

PHP

$encryptionInfo = new Google_Service_Dfareporting_EncryptionInfo();
$encryptionInfo->setEncryptionEntityId($values['encryption_entity_id']);
$encryptionInfo->setEncryptionEntityType($values['encryption_entity_type']);
$encryptionInfo->setEncryptionSource($values['encryption_source']);

Python

# Construct the encryption info.
encryption_info = {
    'encryptionEntityId': encryption_entity_id,
    'encryptionEntityType': encryption_entity_type,
    'encryptionSource': encryption_source
}

Ruby

# Construct the encryption info.
encryption_info = DfareportingUtils::API_NAMESPACE::EncryptionInfo.new(
  encryption_entity_id: encryption[:entity_id],
  encryption_entity_type: encryption[:entity_type],
  encryption_source: encryption[:source]
)

โปรดทราบว่าคำขอแทรกแต่ละรายการจะมีออบเจ็กต์ EncryptionInfo ได้เพียงรายการเดียว ซึ่งหมายความว่า Conversion ทั้งหมดที่รวมอยู่ในคำขอที่ระบุต้องมาจากแหล่งที่มาเดียวกันและใช้เอนทิตีการเข้ารหัสเดียวกัน

สร้างคำขอแทรก

ขั้นตอนสุดท้ายในกระบวนการนี้คือการอัปโหลด Conversion ด้วยการเรียกไปยัง batchinsert เมธอดนี้ยอมรับออบเจ็กต์ ConversionsBatchInsertRequest ซึ่งจะรวมชุด Conversion ที่จะอัปโหลดเข้ากับข้อมูลการเข้ารหัสที่เกี่ยวข้อง (เมื่อจำเป็น)

C#

// Insert the conversion.
ConversionsBatchInsertRequest request = new ConversionsBatchInsertRequest();
request.Conversions = new List<Conversion>() { conversion };
request.EncryptionInfo = encryptionInfo;

ConversionsBatchInsertResponse response =
    service.Conversions.Batchinsert(request, profileId).Execute();

Java

ConversionsBatchInsertRequest request = new ConversionsBatchInsertRequest();
request.setConversions(ImmutableList.of(conversion));
request.setEncryptionInfo(encryptionInfo);

ConversionsBatchInsertResponse response = reporting.conversions()
    .batchinsert(profileId, request).execute();

PHP

$batch = new Google_Service_Dfareporting_ConversionsBatchInsertRequest();
$batch->setConversions([$conversion]);
$batch->setEncryptionInfo($encryptionInfo);

$result = $this->service->conversions->batchinsert(
    $values['user_profile_id'],
    $batch
);

Python

# Insert the conversion.
request_body = {
    'conversions': [conversion],
    'encryptionInfo': encryption_info
}
request = service.conversions().batchinsert(profileId=profile_id,
                                            body=request_body)
response = request.execute()

Ruby

# Construct the batch insert request.
batch_insert_request =
  DfareportingUtils::API_NAMESPACE::ConversionsBatchInsertRequest.new(
    conversions: [conversion],
    encryption_info: encryption_info
  )

# Insert the conversion.
result = service.batchinsert_conversion(profile_id, batch_insert_request)

โปรดทราบว่า Campaign Manager 360 จะพยายามแทรก Conversion แต่ละรายการในคำขอของคุณ ตามความพยายามอย่างเต็มที่ แทนที่จะแทรกทั้งชุดเป็น ธุรกรรมแบบทั้งหมดหรือไม่มีเลย หาก Conversion บางรายการในกลุ่มแทรกล้มเหลว ระบบอาจยังคงแทรก Conversion อื่นๆ ได้สำเร็จ ดังนั้น เราขอแนะนำให้คุณ ตรวจสอบ ConversionsBatchInsertResponse ที่ส่งคืนมา เพื่อพิจารณาสถานะของ Conversion แต่ละรายการ

C#

// Handle the batchinsert response.
if (!response.HasFailures.Value) {
  Console.WriteLine("Successfully inserted conversion for encrypted user ID {0}.",
      conversionUserId);
} else {
  Console.WriteLine("Error(s) inserting conversion for encrypted user ID {0}:",
      conversionUserId);

  ConversionStatus status = response.Status[0];
  foreach(ConversionError error in status.Errors) {
    Console.WriteLine("\t[{0}]: {1}", error.Code, error.Message);
  }
}

Java

if (!response.getHasFailures()) {
  System.out.printf("Successfully inserted conversion for encrypted user ID %s.%n",
      encryptedUserId);
} else {
  System.out.printf("Error(s) inserting conversion for encrypted user ID %s:%n",
      encryptedUserId);

  // Retrieve the conversion status and report any errors found. If multiple conversions
  // were included in the original request, the response would contain a status for each.
  ConversionStatus status = response.getStatus().get(0);
  for (ConversionError error : status.getErrors()) {
    System.out.printf("\t[%s]: %s.%n", error.getCode(), error.getMessage());
  }
}

PHP

if (!$result->getHasFailures()) {
    printf(
        'Successfully inserted conversion for encrypted user ID %s.',
        $values['encrypted_user_id']
    );
} else {
    printf(
        'Error(s) inserting conversion for encrypted user ID %s:<br><br>',
        $values['encrypted_user_id']
    );

    $status = $result->getStatus()[0];
    foreach ($status->getErrors() as $error) {
        printf('[%s] %s<br>', $error->getCode(), $error->getMessage());
    }
}

Python

if not response['hasFailures']:
  print ('Successfully inserted conversion for encrypted user ID %s.'
         % encrypted_user_id)
else:
  print ('Error(s) inserting conversion for encrypted user ID %s.'
         % encrypted_user_id)

  status = response['status'][0]
  for error in status['errors']:
    print '\t[%s]: %s' % (error['code'], error['message'])

Ruby

if result.has_failures
  puts format('Error(s) inserting conversion for encrypted user ID %s.',
    encrypted_user_id)

  status = result.status[0]
  status.errors.each do |error|
    puts format("\t[%s]: %s", error.code, error.message)
  end
else
  puts format('Successfully inserted conversion for encrypted user ID %s.',
    encrypted_user_id)
end

ฟิลด์ status ของการตอบกลับดังที่เห็นด้านบนจะมีออบเจ็กต์ ConversionStatus สำหรับ Conversion ทุกรายการ ที่รวมอยู่ในคำขอเดิม หากคุณสนใจเฉพาะ Conversion ที่ แทรกไม่สําเร็จ คุณสามารถใช้ฟิลด์ hasFailures เพื่อพิจารณาอย่างรวดเร็วว่ามี Conversion ใดในกลุ่มที่ระบุซึ่งไม่สําเร็จหรือไม่

ยืนยันว่าระบบประมวลผล Conversion แล้ว

โดยทั่วไปแล้ว ระบบจะประมวลผล Conversion ที่อัปโหลดและพร้อมให้รายงานภายใน 24 ชั่วโมง หากต้องการยืนยันว่าระบบประมวลผล Conversion ที่คุณอัปโหลดแล้วหรือไม่ เราขอแนะนําให้เรียกใช้รายงานการแสดงผล ของ Floodlight รายงานเหล่านี้จะแสดงทั้ง Conversion ที่ระบุแหล่งที่มา (เชื่อมโยงกับโฆษณา) และ Conversion ที่ไม่ได้ระบุแหล่งที่มาโดยค่าเริ่มต้น ซึ่งแตกต่างจากรายงานการระบุแหล่งที่มาอื่นๆ จึงเหมาะอย่างยิ่งสำหรับการตรวจสอบอย่างรวดเร็วว่า Conversion ที่คุณส่งมาถึง Campaign Manager 360 หรือไม่