تبدیل ها را ویرایش کنید

این راهنما دستورالعمل‌های دقیقی برای ویرایش تبدیل‌ها با استفاده از سرویس Conversions API کمپین منیجر ۳۶۰ ارائه می‌دهد. قبل از ادامه، توصیه می‌شود برای آشنایی با تبدیل‌های آفلاین و آشنایی با مفاهیم مورد بحث در این راهنما، بخش «مرور کلی» را مطالعه کنید.

قبل از اینکه شروع کنی

این گردش کار ویرایش به شما امکان می‌دهد quantity و value تبدیل‌های آنلاین و آفلاین موجود را تغییر دهید. برای انجام این کار، باید مقادیری را ارائه دهید که به طور منحصر به فرد تبدیل‌های مورد ویرایش را مشخص کنند. بسته به نوع تبدیل‌هایی که ویرایش می‌کنید، این مقادیر را به روش‌های مختلفی به دست خواهید آورد:

  • مقادیر لازم برای شناسایی تبدیل‌های آنلاین را می‌توان از Data Transfer دریافت کرد.

  • مقادیر لازم برای شناسایی تبدیل‌های آفلاین در ConversionsBatchInsertResponse درخواست‌های batchinsert موفق بازگردانده می‌شوند.

زمانی که با موفقیت تبدیلی از هر نوع را ویرایش کردید، ConversionsBatchUpdateResponse شامل مقادیر لازم برای انجام ویرایش‌های بعدی خواهد بود.

پیکربندی منابع تبدیل

اولین قدم در گردش کار ویرایش شامل ایجاد یک یا چند شیء منبع Conversion است.

فیلدهای زیر برای شناسایی یک تبدیل برای ویرایش استفاده می‌شوند. این فیلدها الزامی هستند و باید دقیقاً با یک تبدیل موجود مطابقت داشته باشند.

میدان توضیحات

encryptedUserId یا gclid یا dclid یا matchid یا mobileDeviceId

شناسه کاربری رمزگذاری‌شده، شناسه کلیک گوگل، شناسه کلیک نمایشی، شناسه تطابق یا شناسه دستگاه تلفن همراهی که تبدیل را ایجاد کرده است.
floodlightActivityId فعالیت Floodlight که تبدیل به آن نسبت داده شده است.
floodlightConfigurationId پیکربندی Floodlight که توسط فعالیت مشخص شده استفاده می‌شود.
ordinal شناسه‌ی حذف داده‌های تکراری مرتبط با تبدیل.
timestampMicros مهر زمانی تبدیل، بر حسب میکروثانیه از زمان آغاز یونیکس.

فیلدهایی که قابل ویرایش هستند در زیر فهرست شده‌اند.

این فیلدها الزامی هستند و مقادیری که شما ارائه می‌دهید، در هنگام ویرایش تبدیل، جایگزین مقادیر از پیش موجود خواهند شد.

میدان توضیحات
quantity تعداد موارد مرتبط با تبدیل.
value میزان درآمد حاصل از تبدیل.

این فیلدها اختیاری هستند. اگر مقدار آنها تنظیم نشود، بدون تغییر باقی خواهند ماند.

میدان توضیحات
customVariables متغیرهای سفارشی تبدیل را نمایش می‌دهند. اگر متغیر تنظیم شده باشد، مقدار را به‌روزرسانی یا درج می‌کند. اگر تنظیم نشده باشد، مقدار متغیر بدون تغییر باقی می‌ماند.

تمام فیلدهای دیگر ذکر شده در مستندات مرجع پشتیبانی نشده و قابل تغییر نیستند. گنجاندن فیلدهای پشتیبانی نشده در درخواست ویرایش شما منجر به خطا خواهد شد. اگر تبدیلی که ویرایش می‌شود حاوی مقادیر از پیش موجود برای هر فیلد پشتیبانی نشده‌ای باشد، آن مقادیر به طور خودکار حفظ می‌شوند.

مثال زیر ایجاد یک شیء منبع تبدیل ساده برای ویرایش را نشان می‌دهد:

سی شارپ

// 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;

جاوا

// 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);

پی اچ پی

// 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']);

پایتون

# 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

روبی

# 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

اطلاعات رمزگذاری را مشخص کنید

اگر تبدیل‌های ویرایش‌شده با شناسه‌های کاربری رمزگذاری‌شده مرتبط هستند، باید جزئیاتی در مورد نحوه رمزگذاری آنها به عنوان بخشی از درخواست ویرایش ارائه دهید. برای جزئیات بیشتر به راهنمای آپلود تبدیل‌ها مراجعه کنید.

در صورت لزوم، ایجاد یک شیء EncryptionInfo که این مقادیر را مشخص می‌کند، دومین مرحله در گردش کار ویرایش است:

سی شارپ

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

جاوا

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

پی اچ پی

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

پایتون

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

روبی

# 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]
)

ایجاد درخواست به‌روزرسانی

مرحله آخر در این فرآیند، ویرایش تبدیل‌ها با فراخوانی batchupdate است. این متد یک شیء ConversionsBatchUpdateRequest را می‌پذیرد که مجموعه تبدیل‌هایی را که باید ویرایش شوند با اطلاعات رمزگذاری مرتبط با آنها (در صورت لزوم) ترکیب می‌کند:

سی شارپ

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

ConversionsBatchUpdateResponse response =
    service.Conversions.Batchupdate(request, profileId).Execute();

جاوا

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

ConversionsBatchUpdateResponse response = reporting.conversions()
    .batchupdate(profileId, request).execute();

پی اچ پی

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

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

پایتون

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

روبی

# 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 تلاش می‌کند تا هر تبدیل در درخواست شما را بر اساس بهترین تلاش ویرایش کند، نه اینکه کل دسته را به عنوان یک تراکنش همه یا هیچ به‌روزرسانی کند. اگر برخی از تبدیل‌ها در یک دسته به‌روزرسانی نشوند، ممکن است برخی دیگر همچنان با موفقیت به‌روزرسانی شوند. بنابراین، توصیه می‌شود ConversionsBatchUpdateResponse برگردانده شده را بررسی کنید تا وضعیت هر تبدیل را تعیین کنید:

سی شارپ

// 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);
  }
}

جاوا

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());
  }
}

پی اچ پی

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());
    }
}

پایتون

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']))

روبی

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 برای هر تبدیل موجود در درخواست اصلی خواهد بود. اگر فقط به تبدیل‌هایی که به‌روزرسانی نشده‌اند علاقه‌مند هستید، می‌توانید از فیلد hasFailures برای تعیین سریع اینکه آیا تبدیلی در دسته ارائه شده با شکست مواجه شده است یا خیر، استفاده کنید.