Get campaign data

592 views
Skip to first unread message

Shafayet Emon

unread,
Aug 10, 2023, 3:07:13 PM8/10/23
to Google Ads API and AdWords API Forum
Hi,
I want to get the following values for campaigns. How can i get these values using api? What should be the query?

Expected values:

Campaign status
Campaign
Budget name
Currency code
Budget
Budget type
Status
Status reasons
Campaign type
Cost
Impr.
Clicks
CTR
Interaction rate
Search impr. share
Search lost IS (budget)
View-through conv.
Optimization score
Viewable CTR
Viewable impr.
Conv. rate
Conv. value
Conv. value / cost
Conversions
Cost / conv.
Impr. (Top) %
Avg. CPC
Conv. value (by conv. time)
Conversions (by conv. time)
Orders
Avg. cart size
Cross-sell revenue
Revenue
Search lost IS (rank)
Bounce rate
Avg. impr. freq. / user (7 days)

Google Ads API Forum Advisor

unread,
Aug 10, 2023, 6:51:19 PM8/10/23
to shafaye...@gmail.com, adwor...@googlegroups.com

Hi,

I hope you're doing well today.

I suggest you utilize the campaign query builder (https://developers.google.com/google-ads/api/fields/v14/campaign_query_builder) to determine the list of available fields for the campaign resource. If you're unable to find some of the metrics you need, please let us know the field name for our reference. Also, since the API only reflects the UI, kindly provide a UI screenshot as well of the field you're looking for so we can assist you in confirming if it's supported in the API or not.

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

Thanks,
 
Google Logo Google Ads API Team


Google Ads API Forum Advisor

unread,
Aug 10, 2023, 6:53:45 PM8/10/23
to shafaye...@gmail.com, adwor...@googlegroups.com

Hi,

Just to add on my previous response, you may send the field names and UI screenshots to us, if needed, via Reply privately to author option.

Shafayet Emon

unread,
Aug 11, 2023, 12:44:38 AM8/11/23
to Google Ads API and AdWords API Forum
Field names and UI Screenshot addedgoogle ads data.png

Google Ads API Forum Advisor

unread,
Aug 11, 2023, 1:56:50 AM8/11/23
to shafaye...@gmail.com, adwor...@googlegroups.com

Hi Shafayet,

Thank you for the reply.

You may try the below sample query and utilize Campaign Builder (https://developers.google.com/google-ads/api/fields/v14/campaign_query_builder) to see the selectable fields you may use when selecting campaign resource attributes:

"SELECT campaign.status, campaign.name, campaign_budget.name, customer.currency_code, campaign.campaign_budget, campaign_budget.type, campaign.primary_status, campaign.primary_status_reasons, campaign.advertising_channel_type, metrics.cost_micros, metrics.impressions, metrics.clicks, metrics.ctr, metrics.interaction_rate, metrics.search_impression_share, metrics.search_budget_lost_impression_share, metrics.view_through_conversions, campaign.optimization_score, customer.optimization_score, metrics.active_view_ctr, metrics.active_view_impressions, metrics.conversions_value, metrics.current_model_attributed_conversions_value_per_cost, metrics.conversions, metrics.cost_per_conversion, metrics.top_impression_percentage, metrics.average_cpc, metrics.value_per_all_conversions_by_conversion_date, metrics.value_per_conversions_by_conversion_date, metrics.conversions_by_conversion_date, metrics.all_conversions_from_order, metrics.bounce_rate FROM campaign"

On the other hand, if the query we have provided is still not what you are referring to, you may provide us with the entire UI screenshot without cropping, including the customer ID, where you can see the expected data you want to retrieve in the API. We asked that as the Google Ads API mirrors the Google Ads UI. Whatever data shows on the Ads UI report, the API should pull it the same, and upon checking the screenshot you have provided, it seems not to have been taken from the exact Google Ads UI. 

You may then send the requested information via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.
 

Varinder Sohal

unread,
May 22, 2024, 9:25:01 AM5/22/24
to Google Ads API and AdWords API Forum
Hi,
Thank you for this conversation. It has been very helpful. However, I did not get the values when using metrics.conversations. It seems like something might be missing when running the campaign, as it has been showing a value of 0 for the past two months.

Google Ads API Forum Advisor

unread,
May 22, 2024, 10:23:19 AM5/22/24
to varinde...@gmail.com, adwor...@googlegroups.com
Hi,

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

Kindly provide us with the uncropped screenshot of the Google Ads account where the values are showing zero and updated complete API logs (request and response with request-id and request header) generated at your end so that we can investigate why the metrics.conversations are not returned via the API.

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.

You can send the details via Reply privately to the author option, or direct private reply to this email.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02nqkUS:ref" (ADR-00192758)


Thanks,
 
Google Logo Google Ads API Team


Varinder Sohal

unread,
May 23, 2024, 3:16:17 AM5/23/24
to Google Ads API and AdWords API Forum
https://nimb.ws/JL3FY4E

Here is the screenshot of ads dashboard.

Following is the request method:

public static function getGoogleAdCampaigns(GoogleAdsClient $googleAdsClient, int $customerId, $startDate, $endDate) {
$googleAdsServiceClient = $googleAdsClient->getGoogleAdsServiceClient();
$query = "SELECT campaign.id, campaign.name,campaign.status, metrics.impressions,metrics.interactions, metrics.clicks, metrics.conversions, metrics.ctr, metrics.average_cpc, metrics.cost_micros FROM campaign WHERE segments.date >= '$startDate' AND segments.date <= '$endDate'";

/** @var GoogleAdsServerStreamDecorator $stream */
$stream = $googleAdsServiceClient->searchStream(
SearchGoogleAdsStreamRequest::build($customerId, $query)
);
$campaigns = [];

foreach ($stream->iterateAllElements() as $googleAdsRow) {
/** @var GoogleAdsRow $googleAdsRow */
$campaigns[] = [
'id' => $googleAdsRow->getCampaign()->getId(),
'name' => $googleAdsRow->getCampaign()->getName(),
'status' => $googleAdsRow->getCampaign()->getStatus(),
'impressions' => $googleAdsRow->getMetrics()->getImpressions(),
'clicks' => $googleAdsRow->getMetrics()->getClicks(),
'conversions' => $googleAdsRow->getMetrics()->getConversions(),
'ctr' => $googleAdsRow->getMetrics()->getCtr(),
'average_cpc' => $googleAdsRow->getMetrics()->getAverageCpc(),
'cost_micros' => $googleAdsRow->getMetrics()->getCostMicros(),
'interactions' => $googleAdsRow->getMetrics()->getInteractions(),
'revenue_micros' => $googleAdsRow->getMetrics()->getRevenueMicros(),
];
}

echo json_encode($campaigns);
exit();

Google Ads API Forum Advisor

unread,
May 23, 2024, 9:31:25 AM5/23/24
to varinde...@gmail.com, adwor...@googlegroups.com
Hi,

In order to investigate the issue from our end, we need the customer ID and the campaign ID, so I would request you to share those details. 

Varinder Sohal

unread,
Jun 11, 2024, 1:49:21 AM6/11/24
to Google Ads API and AdWords API Forum
Hi,
I get the conversions when I increase the recommended budget thank you for that but now I want to get the revenue. I believe it is appropriate to consider the conversion value as the revenue if not please suggest to me how can I get the revenue Please let me know if you need anything else.
Thanks!

Varinder Sohal

unread,
Jun 11, 2024, 5:53:08 AM6/11/24
to Google Ads API and AdWords API Forum
Hi,

I also want to know if it is possible to get metrics for leads and cost per lead. Despite reading the metrics documentation, I haven't found any clear references. Please let me know if you have any insights on this.

Thanks!

Google Ads API Forum Advisor

unread,
Jun 11, 2024, 7:20:42 AM6/11/24
to varinde...@gmail.com, adwor...@googlegroups.com
Hi,

Yes, you can consider conversion value as revenue in Google Ads. To calculate your revenue, multiply your conversions by your average revenue per conversion. For example, 30 conversions x $50 per conversion = a total revenue of $1500. I would recommend you refer to this help center article on How to estimate conversion value for more information.

To get metrics for leads, you can use metrics.conversions and metrics.cost_per_conversion to obtain metrics for cost per lead.

I hope this clarifies. Let us know if you have any other questions.

Varinder Sohal

unread,
Jun 11, 2024, 7:56:48 AM6/11/24
to Google Ads API and AdWords API Forum

Hi,

Thanks for your response!

I noticed that in your reply, you're treating conversions and leads as the same thing. However, I believe there's a distinction: conversions refer to those who have actually purchased the product, while leads are those who have shown interest and are willing to buy the product. How can we use the same metric key for both conversions and leads?

Could you clarify this for me?

Google Ads API Forum Advisor

unread,
Jun 11, 2024, 2:24:10 PM6/11/24
to varinde...@gmail.com, adwor...@googlegroups.com
Hi,

Yes, your understanding is correct. I would like to mention that if you set the user_identifiers while uploading conversions using only click IDs, it is treated as a conversion for leads. The conversion for leads is obtained by using the metrics.conversions and metrics.cost_per_conversion to obtain metrics for cost per lead. For more information, you can refer to this document.

Hope this helps!

Varinder Sohal

unread,
Jun 11, 2024, 11:48:42 PM6/11/24
to Google Ads API and AdWords API Forum
Hi,
Thanks for your response!
Now I would like to know what changes are needed in following tracking code to track the leads. Right now I'm monitoring conversions and conversions value.

<script>
gtag('event', 'conversion', {'send_to': '-----',
'value': 123.05,
'currency': 'USD'
});
</script>

Google Ads API Forum Advisor

unread,
Jun 12, 2024, 6:38:56 AM6/12/24
to varinde...@gmail.com, adwor...@googlegroups.com
Hi,

I will check with our team regarding your issue and one of my team members will reach out to you once we have an update on this. Meanwhile, your patience is highly appreciated.


This message is in relation to case "ref:!00D1U01174p.!5004Q02nqkUS:ref" (ADR-00192758)

Thanks,

 
Google Logo Google Ads API Team

Register for the upcoming workshop: Performance Max and the Google Ads API!
 


Google Ads API Forum Advisor

unread,
Jun 13, 2024, 9:00:22 AM6/13/24
to varinde...@gmail.com, adwor...@googlegroups.com
Hi,

I would recommend that you reach out to the Google Ads Product support team for tag setup issues.

Please note that our team can only assist with the technical queries or concerns related to the Google Ads API.

Thanks for your understanding.

 
This message is in relation to case "ref:!00D1U01174p.!5004Q02nqkUS:ref" (ADR-00192758)

Thanks,
 
Google Logo Google Ads API Team


Reply all
Reply to author
Forward
0 new messages