I am trying to get hotel performance report using below code and get this error :
PHP Fatal error: Call to undefined method Google\Ads\GoogleAds\V0\Services\GoogleAdsRow::getHotelCheckInDayOfWeek() in /home/reports/gha/google-ads-php/examples/Reporting/GetHotelAdsPerformance.php on line 132
Does anybody has a working example of how to get segment values from the query results?
public static function runExample(GoogleAdsClient $googleAdsClient, $customerId)
{
$googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
// Creates a query that retrieves hotel-ads statistics for each campaign and ad group.
// Returned statistics will be segmented by the check-in day of week and length of stay.
$query =
. "campaign.advertising_channel_type, "
. "ad_group.status, "
. "metrics.impressions, "
. "metrics.hotel_average_lead_value_micros, "
. "segments.hotel_check_in_day_of_week, "
. "segments.hotel_length_of_stay "
. "FROM hotel_performance_view "
. "WHERE segments.date DURING LAST_7_DAYS "
. "AND campaign.advertising_channel_type = 'HOTEL' "
. "AND ad_group.status = 'ENABLED' "
. "ORDER BY metrics.impressions DESC "
. "LIMIT 50";
// 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 each row.
foreach ($response->iterateAllElements() as $googleAdsRow) {
/** @var GoogleAdsRow $googleAdsRow */
// Note: A mapping of enum names to values for days of week can be found at
// DayOfWeek.php.
printf(
"Ad group ID %d in campaign ID %d "
. "with hotel check-in on %d and %d day(s) of stay "
. "had %d impression(s) and %d average lead value (in micros) "
. "during the last 7 days.%s",
$googleAdsRow->getAdGroup()->getId()->getValue(),
$googleAdsRow->getCampaign()->getId()->getValue(),
$googleAdsRow->getHotelCheckInDayOfWeek(),
$googleAdsRow->getHotelLengthOfStay()->getValue(),
$googleAdsRow->getMetrics()->getImpressions()->getValue(),
$googleAdsRow->getMetrics()->getHotelAverageLeadValueMicros()->getValue(),
PHP_EOL
);
}
}