'How to get the keyword using Google Ads API from click_view?
I get data by GCLID
and I want to get the keyword I don`t know how please help me.
On the query I get click_view.keyword_info.text
and I try to print it with
getKeywordInfo()->getText();
Here is my code:
$query =
"SELECT click_view.gclid,click_view.keyword_info.text,ad_group.id,ad_group.name,"
."campaign.id,campaign.name,segments.click_type,segments.date "
. "FROM click_view "
. "WHERE segments.date DURING TODAY and click_view.gclid = '$gclid' "
. "LIMIT 5";
$stream = $googleAdsServiceClient->searchStream(
123456789,
$query
);
foreach ($stream->iterateAllElements() as $googleAdsRow) {
$campaign = $googleAdsRow->getCampaign();
$adGroup = $googleAdsRow->getAdGroup();
$adGroupCriterion = $googleAdsRow->getAdGroupCriterion();
$metrics = $googleAdsRow->getMetrics();
$click_view=$googleAdsRow->getClickView();
printf(
"Keyword text '%s' with \n"
. "Gclid %s \n"
."AD Group Name - '%s' \n"
. "AD Group ID - %d \n"
. "Campaign Name '%s' \n",
$click_view->getKeyword()->getText(),
$click_view->getGclid(),
$adGroup->getName(),
$adGroup->getId(),
$campaign->getName(),
PHP_EOL
);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|