CAMPAIGN_PERFORMANCE_REPORT

55 views
Skip to first unread message

Alpine

unread,
Feb 7, 2017, 12:42:35 PM2/7/17
to AdWords API Forum

I need some statistic for campigns, for example, Impressions, Clicks, etc.
I see the view CAMPAIGN_PERFORMANCE_REPORT contains the fields I need, but it is only to export to a file in some formats.
I need to get the data as an object to work with it in C#. I have a class Campaigns and performance and I would need to populate my object.
What table or view in AdWords API can give me the performance fields for campaigns, ads, keywords?

Thank you

Zweitze

unread,
Feb 8, 2017, 4:51:31 AM2/8/17
to AdWords API Forum
The .NET API has a different method where the report is retrieved as a .NET stream.
You can then initialize a new class "CsvReader" (open source) and feed that stream. That class behaves like an IDataReader. You can feed that into a LinQ class, if necessary.

That is about the idea. To give you an idea about my setup:
My goal is to get the data into a temp table on SQL Server. And I don't like CSV output, I prefer XML (with good reason, the last few years had quite a few problems and changes in CSV, but never in XML). So:

1. Request the report as GZIPPED_XML, get a stream
2. Copy that stream to a MemoryStream. This makes sure that the report is read as fast as possible. You can't keep the report stream open forever, at some time Google will close it.
3. Feed the MemoryStream to a GZipStream to decode the GZip.
4. Feed that stream to a self-made class that generates an IDataReader. Essentially it reads the XML, parses date strings in DateTime, number strings in doubles, integer string in longs, and deals will special Google pecularities like appended percentages, giving '--' for NULL etc.etc.
5. Feed that IDataReader to a SqlBulkCopy

This sounds very slow but performance is stunning, reading 20,000 to 50,000 records per second. Waiting for the report from Google takes more time.
I can't share sources, just telling this so you know which solution you should be looking for.

Alpine

unread,
Feb 8, 2017, 4:59:14 AM2/8/17
to AdWords API Forum
Thank you so much, I will try to do it. this is new for me :)
Reply all
Reply to author
Forward
0 new messages