googleads / google-ads-php

Google Ads API Client Library for PHP
https://developers.google.com/google-ads/api/docs/client-libs/php
Apache License 2.0
294 stars 262 forks source link

GenerateKeywordIdeas & GenerateKeywordForecastMetrics not working #919

Closed aqeelashraf closed 1 year ago

aqeelashraf commented 1 year ago

Hi,

I am facing the same issue GenerateKeywordForecastMetrics as there is no code example available. Below lines not working:

$KeywordPlanIdeaServiceClient = $googleAdsClient->getKeywordPlanIdeaServiceClient(); $generateKeywordForecastMetricsResponse = $KeywordPlanIdeaServiceClient->generateKeywordForecastMetrics( ResourceNames::forCampaign($customerId, $keywordCampaignId) );

Please let me know what is wrong in above lines?

I read at https://github.com/googleads/google-ads-php/issues/918 where it is mentioned that we can use it in similar way like GenerateKeywordIdeas.

I also tried to use the GenerateKeywordIdeas using the example file available GenerateKeywordIdeas.php

You can call the same at: https://www.one-ranking.com/google-ads-php/GenerateKeywordIdeas.php

It is also not working even I didn't changed anything. Just put the values etc.

fiboknacky commented 1 year ago

We're working on the code example. Please stay tuned.

You can call the same at: https://www.one-ranking.com/google-ads-php/GenerateKeywordIdeas.php

Can you share the code instead? Did you run our example as is?

aqeelashraf commented 1 year ago

Yes, I run the example as it is available. Use the same file GenerateKeywordIdeas.php, file attached

Please also let me know when the GenerateKeywordForecastMetrics example will be ready. Thanks

On Wed, Jun 21, 2023 at 1:24 PM Thanet Knack Praneenararat < @.***> wrote:

We're working on the code example. Please stay tuned.

You can call the same at: https://www.one-ranking.com/google-ads-php/GenerateKeywordIdeas.php

Can you share the code instead? Did you run our example as is?

— Reply to this email directly, view it on GitHub https://github.com/googleads/google-ads-php/issues/919#issuecomment-1600406619, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACNIBDEGCXZ5ERICFKAR4TXMKVSFANCNFSM6AAAAAAZOLXYX4 . You are receiving this because you authored the thread.Message ID: @.***>

-- Best Regards,

Aqeel Ashraf

fiboknacky commented 1 year ago

I also tried to use the GenerateKeywordIdeas using the example file available GenerateKeywordIdeas.php

Please note also that it's not necessary that all combination of parameters will lead to the result returned. There are many factors that come into play too.

In other words, if the parameters are correct, it can still return nothing. But if it returns an exception, then please seek help from the Google Ads API forum. They'll help you identify what values are wrong.

As for the example, we'll surely update the release notes when it's ready. We don't have an ETA now, but should be within 1-2 months unless anything is changed.

aqeelashraf commented 1 year ago

Thanks for the quick reply. Is it possible that you send the file with parameters / values added like location, keywords etc. that works and return data? I want to see it working so it will be easier for me to integrate in my code. Thanks

On Wed, Jun 21, 2023 at 2:01 PM Thanet Knack Praneenararat < @.***> wrote:

I also tried to use the GenerateKeywordIdeas using the example file available GenerateKeywordIdeas.php

Please note also that it's not necessary that all combination of parameters will lead to the result returned. There are many factors that come into play too.

In other words, if the parameters are correct, it can still return nothing. But if it returns an exception, then please seek help from the Google Ads API forum https://groups.google.com/g/adwords-api. They'll help you identify what values are wrong.

As for the example, we'll surely update the release notes when it's ready. We don't have an ETA now, but should be within 1-2 months unless anything is changed.

— Reply to this email directly, view it on GitHub https://github.com/googleads/google-ads-php/issues/919#issuecomment-1600463384, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACNIBBXAD4QSXJTMPAFTHLXMKZ5RANCNFSM6AAAAAAZOLXYX4 . You are receiving this because you authored the thread.Message ID: @.***>

-- Best Regards,

Aqeel Ashraf

fiboknacky commented 1 year ago

Could you please ask the last question on the Google Ads API forum? They would be able to help you with those values more quickly. Thank you.

aqeelashraf commented 1 year ago

Hi,

I already posted the same at Google Ads API forum. But I manage to move 1 step further while calling the GenerateKeywordForecastMetrices. Please see details below:

$KeywordPlanIdeaServiceClient = $googleAdsClient-> getKeywordPlanIdeaServiceClient(); $reqArr = array("customerId" => $customerId, "currencyCode" => "EUR"); $generateKeywordForecastMetricsResponse = $KeywordPlanIdeaServiceClient-> generateKeywordForecastMetrics( $campaigntoforecast, $reqArr);

When I run the above, it shows following error:

Request with ID McC5p-yikN36-NZTR_snFg has failed. Google Ads failure details:date_error: The string date's format should be yyyy-mm-dd.

If I pass the date range, then it start showing Internal Server Error, please see below how I am passing the date range:

$KeywordPlanIdeaServiceClient = $googleAdsClient-> getKeywordPlanIdeaServiceClient(); $reqArr = array( "customerId" => $customerId, "currencyCode" => "EUR", "forecastPeriod" => array( "start_date" => "2023-07-1", "end_date" => "2024-06-30" ) ); $generateKeywordForecastMetricsResponse = $KeywordPlanIdeaServiceClient-> generateKeywordForecastMetrics( $campaigntoforecast, $reqArr);

Could you please have a look at the above code and help send the forecastPeriod (date range) in correct format. Thanks

On Wed, Jun 21, 2023 at 6:41 PM Thanet Knack Praneenararat < @.***> wrote:

Could you please ask the last question on the Google Ads API forum https://groups.google.com/g/adwords-api? They would be able to help you with those values more quickly. Thank you.

— Reply to this email directly, view it on GitHub https://github.com/googleads/google-ads-php/issues/919#issuecomment-1600858953, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACNIBAVUHW535ZU3CZRMM3XML2ZVANCNFSM6AAAAAAZOLXYX4 . You are receiving this because you authored the thread.Message ID: @.***>

-- Best Regards,

Aqeel Ashraf

fiboknacky commented 1 year ago

When in doubt, you can refer to the code.

As can be seen, the method requires a date range to be an object of DateRange, so it's not an array.

aqeelashraf commented 1 year ago

Hi,

Yes, I updated and now there is no error message but the response is empty. Please see below my code:

$KeywordPlanIdeaServiceClient = $googleAdsClient-> getKeywordPlanIdeaServiceClient(); $stDate = "2023-07-01"; $enDate = "2023-12-30"; $dtRange = New DateRange(); $dtRange->setStartDate($stDate); $dtRange->setEndDate($enDate); $reqArr = array("customerId" => $customerId, "currencyCode" => "EUR", "forecastPeriod" => $dtRange); $generateKeywordForecastMetricsResponse = $KeywordPlanIdeaServiceClient-> generateKeywordForecastMetrics($campaigntoforecast, $reqArr); print_r($generateKeywordForecastMetricsResponse);

See below my response:

Google\Ads\GoogleAds\V14\Services\GenerateKeywordForecastMetricsResponse Object

Here is link where you can see the response: https://www.one-ranking.com/google-ads-php/AddKeywordPlan.php

Is there anything wrong in code? Please suggest. Thanks

On Wed, Jun 21, 2023 at 8:51 PM Thanet Knack Praneenararat < @.***> wrote:

When in doubt, you can refer to the code https://github.com/googleads/google-ads-php/blob/main/src/Google/Ads/GoogleAds/V14/Services/Gapic/KeywordPlanIdeaServiceGapicClient.php#L251 .

As can be seen, the method requires a date range to be an object of DateRange https://github.com/googleads/google-ads-php/blob/main/src/Google/Ads/GoogleAds/V14/Common/DateRange.php, so it's not an array.

— Reply to this email directly, view it on GitHub https://github.com/googleads/google-ads-php/issues/919#issuecomment-1601093755, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACNIBBISIGPRNYKT26QMOTXMMJ65ANCNFSM6AAAAAAZOLXYX4 . You are receiving this because you authored the thread.Message ID: @.***>

-- Best Regards,

Aqeel Ashraf

aqeelashraf commented 1 year ago

Hi,

I just found the way to get and print the results. It is mentioned in https://github.com/googleads/google-ads-php/issues/918.

Thanks for your help.

On Thu, Jun 22, 2023 at 3:21 AM Aqeel Ashraf @.***> wrote:

Hi,

Yes, I updated and now there is no error message but the response is empty. Please see below my code:

$KeywordPlanIdeaServiceClient = $googleAdsClient-> getKeywordPlanIdeaServiceClient(); $stDate = "2023-07-01"; $enDate = "2023-12-30"; $dtRange = New DateRange(); $dtRange->setStartDate($stDate); $dtRange->setEndDate($enDate); $reqArr = array("customerId" => $customerId, "currencyCode" => "EUR", "forecastPeriod" => $dtRange); $generateKeywordForecastMetricsResponse = $KeywordPlanIdeaServiceClient-> generateKeywordForecastMetrics($campaigntoforecast, $reqArr); print_r($generateKeywordForecastMetricsResponse);

See below my response:

Google\Ads\GoogleAds\V14\Services\GenerateKeywordForecastMetricsResponse Object

Here is link where you can see the response: https://www.one-ranking.com/google-ads-php/AddKeywordPlan.php

Is there anything wrong in code? Please suggest. Thanks

On Wed, Jun 21, 2023 at 8:51 PM Thanet Knack Praneenararat < @.***> wrote:

When in doubt, you can refer to the code https://github.com/googleads/google-ads-php/blob/main/src/Google/Ads/GoogleAds/V14/Services/Gapic/KeywordPlanIdeaServiceGapicClient.php#L251 .

As can be seen, the method requires a date range to be an object of DateRange https://github.com/googleads/google-ads-php/blob/main/src/Google/Ads/GoogleAds/V14/Common/DateRange.php, so it's not an array.

— Reply to this email directly, view it on GitHub https://github.com/googleads/google-ads-php/issues/919#issuecomment-1601093755, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACNIBBISIGPRNYKT26QMOTXMMJ65ANCNFSM6AAAAAAZOLXYX4 . You are receiving this because you authored the thread.Message ID: @.***>

-- Best Regards,

Aqeel Ashraf

-- Best Regards,

Aqeel Ashraf

fiboknacky commented 1 year ago

Thanks. I'll close this issue for now. Once the example is ready, I'll update #918