2016-07-12 3 views
0

Я установил учетную запись с моей учетной записью mcc и выполнил код отчета о примерах для отчета об эффективности кампании для одного из моих идентификаторов customerclient.google adwords api php library

Это код:

<?php 

// Include the initialization file 
require_once __DIR__ . '/examples/AdWords/Auth/init.php'; 
require_once __DIR__. '/src/Google/Api/Ads/AdWords/Util/v201601/ReportUtils.php'; 


function DownloadCriteriaReportWithAwqlExample(AdWordsUser $user, $filePath, 
    $reportFormat) { 
    // Optional: Set clientCustomerId to get reports of your child accounts 
    $user->SetClientCustomerId('731-721-7585'); 

    // Prepare a date range for the last week. Instead you can use 'LAST_7_DAYS'. 
    // $dateRange = 'ALL_TIME'; 

    // Create report query. 
    $reportQuery = 'SELECT CampaignName, Impressions, Clicks, Ctr, AverageCpc, ' 
     . 'Cost, Date,Conversions,ConversionRate, CostPerConversion,CampaignStatus FROM CAMPAIGN_PERFORMANCE_REPORT ' 
     . 'WHERE CampaignStatus = ENABLED DURING THIS_MONTH'; 

    // Set additional options. 
    $options = array('version' => 'v201601'); 


    // Download report. 
    $reportUtils = new ReportUtils(); 
    $reportUtils->DownloadReportWithAwql($reportQuery, $filePath, $user, 
     $reportFormat, $options); 

    printf("Report was downloaded to '%s'.\n", $filePath); 
} 




try { 

    // Get AdWordsUser from credentials in "../auth.ini" 
    // relative to the AdWordsUser.php file's directory. 
    $user = new AdWordsUser(); 

    // Log every SOAP XML request and response. 
    $user->LogAll(); 

    // Download the report to a file in the same directory as the example. 
    $filePath = dirname(__FILE__) . '/report.csv'; 
    $reportFormat = 'CSV'; 

    // Run the example. 
    DownloadCriteriaReportWithAwqlExample($user, $filePath, $reportFormat); 
} catch (Exception $e) { 
    printf("An error has occurred: %s\n", $e->getMessage()); 
} 

// Don't run the example if the file is being included. 
if (__FILE__ != realpath($_SERVER['PHP_SELF'])) { 
    return; 
} 

Я выполнил этот код и получил отчет в формате CSV, где у меня есть два поля AverageCpc и стоимость.

Оба этих параметра должны быть округлены или должны быть возвращены в том же формате, что и в панели инструментов Google AdWords.

Вот скриншот того, как это выглядит я мой файл CSV

Avg.Cpc | Cost 
9788919 | 362190000 

Но когда я подтверждено с Adwords кампании, это показывает.

Avg.Cpc | Cost 
9.7 | 36.21 

Есть ли какие-либо проблемы с кодом или мне нужно указать некоторые дополнительные параметры для AvgCpc стоимости и затрат отформатировать его правильно ???

ответ

1

Для этого вам необходимо разделить стоимость и среднее значение cpc на 1000000, поэтому вы получите свой формат, прежде чем сможете обрабатывать данные дальше.