How to get Average Cpv from campagn table with GAQL

27 views
Skip to first unread message

임호재

unread,
May 15, 2019, 5:04:07 AM5/15/19
to AdWords API and Google Ads API Forum
Just get error,  

Uncaught Error: Call to a member function getValue()

Why getAverageCpv() is not working. 

My campaign has averge cpv, not null.



public static function runExample(GoogleAdsClient $googleAdsClient, $customerId)
    {
        $googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
        // Creates a query that retrieves all keyword statistics.
        $query =
            "SELECT campaign.id, campaign.name, campaign.status, segments.device, metrics.impressions,
       metrics.clicks, metrics.ctr, metrics.average_cpv, metrics.average_cpc, metrics.cost_micros
FROM campaign
WHERE segments.date DURING YESTERDAY";
        // Issues a search request by specifying page size.
        $response =
            $googleAdsServiceClient->search($customerId, $query, ['pageSize' => self::PAGE_SIZE]);

        // Iterates over all rows in all pages and prints the requested field values for
        // the keyword in each row.
        foreach ($response->iterateAllElements() as $googleAdsRow) {
            /** @var GoogleAdsRow $googleAdsRow */
            $campaign = $googleAdsRow->getCampaign();
$metrics = $googleAdsRow->getMetrics();
            
printf(
                "campaign name '%s' "
                . "ID %d "
. "cpv %s "
. "cost %s "
. "%s",
                $campaign->getName()->getValue(),
                $campaign->getId()->getValue(),
$metrics->getAverageCpv()->getValue(),
$metrics->getCostMicros()->getValue(),
                PHP_EOL
            );

        }
    }

임호재

unread,
May 15, 2019, 5:04:07 AM5/15/19
to AdWords API and Google Ads API Forum
Dear Google API team,


I get Just this Error, our campaign has average cpv not null.

Uncaught Error: Call to a member function getValue()



source :
Reply all
Reply to author
Forward
0 new messages