คู่มือนี้จะแสดงวิธีการโดยละเอียดในการแก้ไข Conversion โดยใช้บริการ Conversions Campaign Manager 360 API ก่อนดําเนินการต่อ เราขอแนะนําให้คุณดูภาพรวมเพื่อดูข้อมูลเบื้องต้นเกี่ยวกับ Conversion ออฟไลน์ และทําความคุ้นเคยกับแนวคิดที่กล่าวถึงในคู่มือนี้
ก่อนเริ่มต้น
เวิร์กโฟลว์การแก้ไขนี้ช่วยให้คุณแก้ไข quantity และ value ของ Conversion ออนไลน์และออฟไลน์ที่มีอยู่ได้ โดยคุณจะต้องระบุค่าที่ระบุ Conversion ที่จะแก้ไขได้อย่างเฉพาะเจาะจง คุณจะได้รับค่าเหล่านี้ด้วยวิธีต่างๆ ขึ้นอยู่กับประเภท Conversion ที่คุณแก้ไข
ดูค่าที่จําเป็นสําหรับระบุ Conversion ออนไลน์ได้จากการโอนข้อมูล
ระบบจะแสดงค่าที่จําเป็นสําหรับระบุ Conversion ออฟไลน์ใน
ConversionsBatchInsertResponseคําขอbatchinsertที่ประสบความสําเร็จ
เมื่อแก้ไข Conversion ประเภทใดประเภทหนึ่งเรียบร้อยแล้ว ConversionsBatchUpdateResponse จะมีค่าที่จําเป็นสําหรับการแก้ไขในภายหลัง
กำหนดค่าทรัพยากร Conversion
ขั้นตอนแรกในเวิร์กโฟลว์การแก้ไขเกี่ยวข้องกับการสร้างออบเจ็กต์ทรัพยากร Conversion อย่างน้อย 1 รายการ
ฟิลด์ต่อไปนี้ใช้เพื่อระบุ Conversion ที่จะแก้ไข คุณต้องกรอกข้อมูลในฟิลด์เหล่านี้และต้องตรงกับ Conversion ที่มีอยู่ทุกประการ
| ช่อง | คำอธิบาย |
|---|---|
|
รหัสผู้ใช้ที่เข้ารหัส, Google Click ID, รหัสคลิก Display, รหัสการทํางานร่วมกัน หรือรหัสอุปกรณ์เคลื่อนที่ที่สร้าง Conversion |
floodlightActivityId |
กิจกรรม Floodlight ที่เป็นแหล่งที่มาของ Conversion |
floodlightConfigurationId |
การกําหนดค่า Floodlight ที่กิจกรรมที่ระบุใช้ |
ordinal |
ตัวระบุการกรองข้อมูลที่ซ้ำกันออกที่เชื่อมโยงกับ Conversion |
timestampMicros |
การประทับเวลาของ Conversion เป็นไมโครวินาทีนับตั้งแต่ Unix Epoch |
ช่องที่แก้ไขได้มีดังนี้
ฟิลด์เหล่านี้เป็นฟิลด์ที่ต้องกรอก และค่าที่คุณระบุจะเขียนทับค่าที่มีอยู่เดิมใน Conversion ที่แก้ไข
| ช่อง | คำอธิบาย |
|---|---|
quantity |
จํานวนรายการที่เชื่อมโยงกับ Conversion |
value |
จํานวนรายได้ที่เกิดจาก Conversion |
ฟิลด์เหล่านี้เป็นฟิลด์ที่ไม่บังคับ ค่าจะไม่มีการเปลี่ยนแปลงหากไม่ได้ตั้งค่า
| ช่อง | คำอธิบาย |
|---|---|
customVariables |
ตัวแปร Floodlight ที่กําหนดเองของ Conversion จะอัปเดตหรือแทรกค่าหากมีการตั้งค่าตัวแปร ค่าของตัวแปรจะไม่มีการเปลี่ยนแปลงหากไม่ได้ตั้งค่า |
ระบบไม่รองรับและแก้ไขไม่ได้สำหรับช่องอื่นๆ ทั้งหมดที่กล่าวถึงในเอกสารอ้างอิง การใส่ช่องที่ไม่รองรับในคำขอแก้ไขจะทำให้เกิดข้อผิดพลาด หาก Conversion ที่แก้ไขมีค่าที่มีอยู่เดิมสําหรับช่องที่ไม่รองรับ ระบบจะเก็บค่าเหล่านั้นไว้โดยอัตโนมัติ
ตัวอย่างด้านล่างแสดงการสร้างออบเจ็กต์แหล่งข้อมูล Conversion ง่ายๆ ที่จะแก้ไข
C#
// Find the Floodlight configuration ID based on the provided activity ID. FloodlightActivity floodlightActivity = service.FloodlightActivities.Get(profileId, floodlightActivityId).Execute(); long floodlightConfigurationId = (long) floodlightActivity.FloodlightConfigurationId; // Construct the conversion object with values that identify the conversion to update. Conversion conversion = new Conversion(); conversion.EncryptedUserId = conversionUserId; conversion.FloodlightActivityId = floodlightActivityId; conversion.FloodlightConfigurationId = floodlightConfigurationId; conversion.Ordinal = conversionOrdinal; conversion.TimestampMicros = conversionTimestamp; // Set the fields to be updated. These fields are required; to preserve a value from the // existing conversion, it must be copied over manually. conversion.Quantity = newQuantity; conversion.Value = newValue;
Java
// Create a conversion object populated with values that identify the conversion to update. Conversion conversion = new Conversion(); conversion.setEncryptedUserId(encryptedUserId); conversion.setFloodlightActivityId(floodlightActivityId); conversion.setFloodlightConfigurationId(floodlightConfigurationId); conversion.setOrdinal(ordinal); conversion.setTimestampMicros(timestampMicros); // Set the fields to be updated. These fields are required; to preserve a value from the // existing conversion, it must be copied over manually. conversion.setQuantity(newQuantity); conversion.setValue(newValue);
PHP
// 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(); // Create a conversion object with values that identify the conversion to // update. $conversion = new Google_Service_Dfareporting_Conversion(); $conversion->setEncryptedUserId($values['encrypted_user_id']); $conversion->setFloodlightActivityId($values['floodlight_activity_id']); $conversion->setFloodlightConfigurationId($floodlightConfigId); $conversion->setOrdinal($values['ordinal']); $conversion->setTimestampMicros($values['timestamp']); // Set the fields to be updated. These fields are required; to preserve a // value from the existing conversion, it must be copied over manually. $conversion->setQuantity($values['new_quantity']); $conversion->setValue($values['new_value']);
Python
# Construct the conversion object with values that identify the conversion # to update. conversion = { 'encryptedUserId': encrypted_user_id, 'floodlightActivityId': floodlight_activity_id, 'floodlightConfigurationId': floodlight_config_id, 'ordinal': ordinal, 'timestampMicros': timestamp } # Set the fields to be updated. These fields are required; to preserve a # value from the existing conversion, it must be copied over manually. conversion['quantity'] = new_quantity conversion['value'] = new_value
Ruby
# Look up the Floodlight configuration ID based on activity ID. floodlight_activity = service.get_floodlight_activity(profile_id, existing_conversion[:floodlight_activity_id]) floodlight_config_id = floodlight_activity.floodlight_configuration_id # Construct the conversion with values that identify the conversion to # update. conversion = DfareportingUtils::API_NAMESPACE::Conversion.new( encrypted_user_id: existing_conversion[:encrypted_user_id], floodlight_activity_id: existing_conversion[:floodlight_activity_id], floodlight_configuration_id: floodlight_config_id, ordinal: existing_conversion[:ordinal], timestamp_micros: existing_conversion[:timestamp] ) # Set the fields to be updated. These fields are required; to preserve a # value from the existing conversion, it must be copied over manually. conversion.quantity = new_quantity conversion.value = new_value
ระบุข้อมูลการเข้ารหัส
หาก Conversion ที่จะแก้ไขเชื่อมโยงกับรหัสผู้ใช้ที่เข้ารหัส คุณจะต้องระบุรายละเอียดเกี่ยวกับการเข้ารหัสรหัสผู้ใช้ดังกล่าวเป็นส่วนหนึ่งของคําขอแก้ไข ดูรายละเอียดได้ในคู่มือการอัปโหลด Conversion
เมื่อจําเป็น การสร้างออบเจ็กต์ EncryptionInfo ที่ระบุค่าเหล่านี้เป็นขั้นตอนที่ 2 ของเวิร์กโฟลว์การแก้ไข
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] )
สร้างคำขออัปเดต
ขั้นตอนสุดท้ายในกระบวนการนี้คือแก้ไข Conversion ด้วยการเรียกใช้ batchupdate เมธอดนี้รับออบเจ็กต์ ConversionsBatchUpdateRequest ซึ่งรวมชุด Conversion ที่จะแก้ไขเข้ากับข้อมูลการเข้ารหัสที่เกี่ยวข้อง (เมื่อจําเป็น)
C#
// Insert the conversion. ConversionsBatchUpdateRequest request = new ConversionsBatchUpdateRequest(); request.Conversions = new List<Conversion>() { conversion }; request.EncryptionInfo = encryptionInfo; ConversionsBatchUpdateResponse response = service.Conversions.Batchupdate(request, profileId).Execute();
Java
ConversionsBatchUpdateRequest request = new ConversionsBatchUpdateRequest(); request.setConversions(ImmutableList.of(conversion)); request.setEncryptionInfo(encryptionInfo); ConversionsBatchUpdateResponse response = reporting.conversions() .batchupdate(profileId, request).execute();
PHP
$batch = new Google_Service_Dfareporting_ConversionsBatchUpdateRequest(); $batch->setConversions([$conversion]); $batch->setEncryptionInfo($encryptionInfo); $result = $this->service->conversions->batchupdate( $values['user_profile_id'], $batch );
Python
# Update the conversion. request_body = { 'conversions': [conversion], 'encryptionInfo': encryption_info } request = service.conversions().batchupdate( profileId=profile_id, body=request_body) response = request.execute()
Ruby
# Construct the batch update request. batch_update_request = DfareportingUtils::API_NAMESPACE::ConversionsBatchUpdateRequest.new( conversions: [conversion], encryption_info: encryption_info ) # Update the conversion. result = service.batchupdate_conversion(profile_id, batch_update_request)
โปรดทราบว่า Campaign Manager 360 จะพยายามแก้ไข Conversion แต่ละรายการในคําขอของคุณอย่างดีที่สุด แทนที่จะอัปเดตทั้งกลุ่มเป็นธุรกรรมแบบ "ทั้งหมดหรือไม่มีอะไรเลย" หากอัปเดต Conversion บางรายการในชุดไม่สําเร็จ Conversion อื่นๆ อาจยังอัปเดตสําเร็จได้ ดังนั้น เราขอแนะนําให้คุณตรวจสอบ ConversionsBatchUpdateResponse ที่แสดงผลเพื่อดูสถานะของ Conversion แต่ละรายการ
C#
// Handle the batchinsert response. if (!response.HasFailures.Value) { Console.WriteLine("Successfully updated conversion for encrypted user ID {0}.", conversionUserId); } else { Console.WriteLine("Error(s) updating 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 updated conversion for encrypted user ID %s.%n", encryptedUserId); } else { System.out.printf("Error(s) updating 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 updated conversion for encrypted user ID %s.', $values['encrypted_user_id'] ); } else { printf( 'Error(s) updating 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 updated conversion for encrypted user ID %s.' % encrypted_user_id) else: print('Error(s) updating 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) updating conversion for encrypted user ID %s.', existing_conversion[: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 updated conversion for encrypted user ID %s.', existing_conversion[:encrypted_user_id]) end
ฟิลด์ status ของการตอบกลับดังที่แสดงด้านบนจะมีออบเจ็กต์ ConversionStatus สําหรับ Conversion ทั้งหมดที่รวมอยู่ในคําขอเดิม หากสนใจเฉพาะ Conversion ที่อัปเดตไม่สําเร็จ คุณสามารถใช้ช่อง hasFailures เพื่อระบุได้อย่างรวดเร็วว่า Conversion ใดในชุดที่ระบุอัปเดตไม่สําเร็จหรือไม่