Campaign Insights breakdown

184 views
Skip to first unread message

Zied Chaari

unread,
May 15, 2019, 9:33:15 AM5/15/19
to AdWords API and Google Ads API Forum
Hi All,

I'm using Google AdWords API, and I want to get my campaign insights beaked by Date, Age, Gender and Device.
Any advise please? 

You can find bellow how I'm getting my campaign insights but without breakdown.

AdWordsUser user = new AdWordsUser(config);

            ReportQuery query = new ReportQueryBuilder()
               .Select("CampaignId", "CampaignName", "Clicks", "Impressions", "Amount", "Cost", "Ctr", "AverageCpc", "AverageCpm")
               .From(ReportDefinitionReportType.CAMPAIGN_PERFORMANCE_REPORT)
               .Where("CampaignStatus").In("ENABLED", "PAUSED")
               .Where("CampaignId").In(campaign_ids)
               .During(ReportDefinitionDateRangeType.LAST_7_DAYS)
               .Build();

            ReportUtilities reportUtilities = new ReportUtilities(user, "v201809", query, DownloadFormat.GZIPPED_XML.ToString());

            try
            {
                using (ReportResponse response = reportUtilities.GetResponse())
                {
                    using (GZipStream gzipStream = new GZipStream(response.Stream, CompressionMode.Decompress))
                    {
                        using (var report = new AwReport<CampaignReportRow>(new AwXmlTextReader(gzipStream), ""))
                        {
                            if(report != null && report.Rows != null && report.Rows.Count() > 0)
                            {
                                CampaignReportRow insights = new CampaignReportRow()
                                {
                                    Clicks = report.Rows.Select(R => R.Clicks).Sum(),
                                    Amount = report.Rows.Select(R => R.Amount).Sum(),
                                    Cost = report.Rows.Select(R => R.Cost).Sum(),
                                    ImpressionReach = report.Rows.Select(R => R.ImpressionReach).Sum(),
                                    Impressions = report.Rows.Select(R => R.Impressions).Sum(),
                                    Ctr = report.Rows.Select(R => R.Ctr).Average(),
                                    AverageCpc = report.Rows.Select(R => R.AverageCpc).Average(),
                                    AverageCpm = report.Rows.Select(R => R.AverageCpm).Average(),
                                };
                                return insights;
                            }
                            else
                            {
                                return new CampaignReportRow();
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw new System.ApplicationException("Failed to download and parse report.", e);
            }

Cheers,
Zied

googleadsapi...@google.com

unread,
May 15, 2019, 4:30:36 PM5/15/19
to AdWords API and Google Ads API Forum
Hello Zied, 

You may use the Campaign Performance Report to segment the data based on Device and Date. The Age and Gender data can be pulled through the Age Range Performance Report and the Gender Performance Report. You may also use the Criteria Performance Report which will return the data as combination of ad group and criteria. 

Could you please give this a try?

Thanks,
Bharani, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

Zied Chaari

unread,
May 16, 2019, 4:18:26 AM5/16/19
to AdWords API and Google Ads API Forum
Hi Bharani,

Should I put the Device and Date attributes in the select element, like bellow?
.Select("CampaignId", "CampaignName", "Clicks", "Impressions", "Amount", "Cost", "Ctr", "AverageCpc", "AverageCpm", "Device", "Date")

I ask you this question because I sill use my Test Ad Account, so all my created campaign return zero metrics.

Thanks,
Zied

googleadsapi...@google.com

unread,
May 16, 2019, 10:20:12 AM5/16/19
to AdWords API and Google Ads API Forum
Hello Zied, 

That's right. You will need to include the Date and Device in the SELECT query. This will segment the data split into different rows based on the Device and Date.

Let me know if you have any questions.

Regards,
Bharani, Google Ads API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    https://ads-developers.googleblog.com/search/label/google_ads_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Zied Chaari

unread,
May 22, 2019, 9:49:17 AM5/22/19
to AdWords API and Google Ads API Forum
Hi Bharani,

I'm getting empty list of insights when I'm trying to get my campaign insights split by date or by device.
I made the same call yesterday (with date breakdown), and I could have some rows. But from today, I'm getting zero row.
I'm using a Test account.

Fiddler couldn't debug my request, so I don't have logs to provide them to you.

Thanks,
Zied.

Google Ads API Forum Advisor Prod

unread,
May 22, 2019, 4:37:34 PM5/22/19
to acteol...@gmail.com, adwor...@googlegroups.com
Hi Zied, 

Could you please share the report query that you're using along with the client customer Id to take a closer look? You may share the details privately via Reply privately to author option.

Regards,
Bharani, Google Ads API Team

ref:_00D1U1174p._5001UAqL5x:ref

Zied Chaari

unread,
May 23, 2019, 4:51:58 AM5/23/19
to AdWords API and Google Ads API Forum
Hi Bharani,

I sent to you the required elements privately.

Thanks,
Zied 

Google Ads API Forum Advisor Prod

unread,
May 23, 2019, 3:01:30 PM5/23/19
to acteol...@gmail.com, adwor...@googlegroups.com
Hello Zied, 

Can you make sure that you set the includeZeroImpressions to true in the request header? This will include the rows with zero impressions. The shared account Id is a Test account, so this will not have any metrics data as the test accounts do not serve any ads. 

Thanks,

Zied Chaari

unread,
May 24, 2019, 4:05:36 AM5/24/19
to AdWords API and Google Ads API Forum
Hi Bharani,

Yes that's it, I didn't set the includeZeroImpressions to true. I thought it is a default value.

Thanks,
Zied
Reply all
Reply to author
Forward
0 new messages