Help:Google Ads API querys/ segments.date not working

100 views
Skip to first unread message

Enzo Patriarca

unread,
Sep 20, 2023, 4:08:56 PM9/20/23
to Google Ads API and AdWords API Forum


$start = Carbon::now()->startOfMonth();

$start = $start->format('Y-m-d');

$end = Carbon::now()->format('Y-m-d');

// dd($start,$end);


$campaignQuery = "SELECT

campaign.id,

campaign.start_date,

campaign.name,

campaign.status,

metrics.clicks,

metrics.impressions,

metrics.cost_micros,

metrics.conversions,

metrics.cost_per_conversion

FROM

campaign";



// WHERE segments.date BETWEEN '{$start}' AND '{$end}'

// ORDER BY campaign.id

// dd($campaignQuery);

// Execute the query to retrieve campaign data

$campaignStream = $googleAdsClient->getGoogleAdsServiceClient()->searchStream($customerId, $campaignQuery);



when i add: // WHERE segments.date BETWEEN '{$start}' AND '{$end}'

// ORDER BY campaign.id stop returning me data 

Google Ads API Forum Advisor

unread,
Sep 26, 2023, 7:32:21 AM9/26/23
to enzo.pa...@joinads.me, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

After reviewing your concern, I understand that the segments.date is not working in the query. I would suggest you make sure that the date range is set correctly in the query and the “ORDER BY campaign.id” clause will sort the results by the campaign ID so make sure the campaign ID is correct. I would suggest you follow the document Date Ranges to get more information.

If the issue still persists, kindly request you to provide us with the complete API logs (request and response with request-id and request header) generated at your end to better assist you.

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java.NetPHPPythonRuby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.

 
This message is in relation to case "ref:_00D1U1174p._5004Q2ozw3y:ref"

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages