Google Groups

Re: why keyword performance report different result by comparing results from HTTP Request and directly from mcc


Minius Jun 18, 2012 2:05 AM
Posted in group: AdWords API Forum
can someone look at my problem? Please

2012 m. birželis 13 d., trečiadienis 10:11:27 UTC+3, Minius rašė:
Hi,

I try to get keyword performance report by fallowing this specification:
https://developers.google.com/adwords/api/docs/guides/reporting?hl=lt.

Everything works fine, except that result are different by comparing with results directly from MCC.
Totals of fallowing field:
clicks, cost
are different than from MCC form the same client and same data range.
Result from MCC
is slightly larger than result from http request using AdHoc method.

Why?
Maybe someone you have suggestions on what to pay attention, or what might be wrong ?

My code looks like:
// Account login details
    $username = "xxx";
    $password = "xxx";
    $customerId = "xxx"; 
    $devToken = "xxx";
     
    // Get an access code for the user
    $url = "https://www.google.com/accounts/ClientLogin";
    $params = array(
        "accountType" => "GOOGLE",
        "Email" => $username,
        "Passwd" => $password,
        "service" => "adwords",
        "source" => "test"
    );
     
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
    //curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $curlData = curl_exec($curl);
    curl_close($curl);
     
    // Parse the response
    $curlData = explode("\n", $curlData);
    $return = array();
    foreach ($curlData as $value) {
        $value = explode("=", $value, 2);
        if (count($value) > 1) {
            $return[$value[0]] = $value[1];
        }
    }
    // Extract the access token
    $authToken = $return["Auth"];
   
   
    #
    $httpHeaders = array(
        "Authorization: GoogleLogin auth=$authToken",
        "clientCustomerId: $customerId",
        "developerToken: $devToken"
    );
   
    #
    $reportDefinition = "<reportDefinition>";
    $reportDefinition .= "<selector>";
    $reportDefinition .= "<fields>Id</fields>";
    $reportDefinition .= "<fields>Date</fields>";
    $reportDefinition .= "<fields>ExternalCustomerId</fields>";
    $reportDefinition .= "<fields>AccountDescriptiveName</fields>";
    $reportDefinition .= "<fields>CampaignId</fields>";
    $reportDefinition .= "<fields>Clicks</fields>";
    $reportDefinition .= "<fields>AverageCpc</fields>";
    $reportDefinition .= "<fields>Cost</fields>";
    $reportDefinition .= "</selector>";
    $reportDefinition .= "<reportName>Keywords Performance Report</reportName>";
    $reportDefinition .= "<reportType>KEYWORDS_PERFORMANCE_REPORT</reportType>";
    $reportDefinition .= "<dateRangeType>LAST_MONTH</dateRangeType>";
    //$reportDefinition .= "<dateRangeType>CUSTOM_DATE</dateRangeType>";
    $reportDefinition .= "<downloadFormat>CSV</downloadFormat>";
    $reportDefinition .= "<includeZeroImpressions>true</includeZeroImpressions>";
    $reportDefinition .= "</reportDefinition>";
     
    $params = array("__rdxml" => $reportDefinition);
   
   
    #
    $url = "https://adwords.google.com/api/adwords/reportdownload/v201109";
 
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_HEADER, false);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
    curl_setopt($curl, CURLOPT_HTTPHEADER, $httpHeaders);
    //curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    $reportData = curl_exec($curl);
    curl_close($curl);
     
    print "$reportData\n";