Unable to get campaigns data to push to database

96 views
Skip to first unread message

lakshmana deepesh

unread,
Feb 7, 2018, 4:04:29 AM2/7/18
to AdWords API Forum
Hi everyone,

I am facing a couple of issues in figuring out what-is-what, in spite of the humungous documentation I am unable to figure out these issues
  1. Which report type should be used to get the campaign level totals. I am trying to get the data in the format of headers
    -campaign_id|campaign_name|CLicks|Impressions|Cost|Conversions.
  2. I have tried to use "CAMPAIGN_PERFORMANCE_REPORT" but I get broken up information at a keyword level, but I am trying to pull the data at a campaign level.
  3. I also need to push the data to a database. In the API documentation, I get samples which will either print the results on my screen or it will create a file on my machine. is there a way where I can get the data in JSON to push it to the database.
  4. I have 7 accounts on my MCC account as of now, the number will increase in the coming days. I don't want to manually hard code the client customer ids into my code as there will be new accounts which will be created. is there a way where I can get the list of client customer ids which are on my MCC ac
I am trying to get this data using python as my code base.

lakshmana deepesh

unread,
Feb 7, 2018, 4:04:29 AM2/7/18
to AdWords API Forum
Hi everyone,

I am facing a couple of issues in figuring out what-is-what, in spite of the humungous documentation I am unable to figure out these issues
  1. Which report type should be used to get the campaign level totals. I am trying to get the data in the format of headers
    -campaign_id|campaign_name|CLicks|Impressions|Cost|Conversions.
  2. I have tried to use "CAMPAIGN_PERFORMANCE_REPORT" but I get broken up information at a keyword level, but I am trying to pull the data at a campaign level.
  1. I also need to push the data to a database. In the API documentation, i get samples which will either print the results on my screen or it will create a file on my machine. is there a way where I can get the data in JSON to push it to the database.
  1. I have 7 accounts on my MCC account as of now, the number will increase in the coming days. I don't want to manually hard code the client customer ids into my code as there will be new accounts which will be created. is there a way where I can get the list of client customer ids which are on my MCC ac

Dhanya Sundararaju (AdWords API Team)

unread,
Feb 7, 2018, 11:57:35 AM2/7/18
to AdWords API Forum
Hi Deepesh,

Please find my responses inline:

Which report type should be used to get the campaign level totals. I am trying to get the data in the format of headers
-campaign_id|campaign_name|CLicks|Impressions|Cost|Conversions.

Your best bet would be Campaign Performance Report. For your reference, other report types are available in this guide.


I have tried to use "CAMPAIGN_PERFORMANCE_REPORT" but I get broken up information at a keyword level, but I am trying to pull the data at a campaign level.

By 'broken up information at a keyword level', do you mean you are getting more rows than the number of campaigns you have? Please note that if you use segmentation, you will have more than one row per campaign. Could you please reply back with your report definition?


I also need to push the data to a database. In the API documentation, i get samples which will either print the results on my screen or it will create a file on my machine. is there a way where I can get the data in JSON to push it to the database.

Unfortunately, the supported download formats do not contain JSON but, you may handle conversion at your end, in your code, for example, by using csv.DictReader in python.


I have 7 accounts on my MCC account as of now, the number will increase in the coming days. I don't want to manually hard code the client customer ids into my code as there will be new accounts which will be created. is there a way where I can get the list of client customer ids which are on my MCC ac
Sure, the get_account_hierarchy sample code will give you a list of all accounts directly under your MCC id and the parallel_report_download sample code will let you download reports in parallel for every account under a MCC. Just be sure to run it against the MCC clientCustomerId.

Also, you may find this documentation on Reporting Basics handy. Please let me know if you have further questions.

Regards,
Dhanya, AdWords API Team

lakshmana deepesh

unread,
Feb 8, 2018, 7:14:49 AM2/8/18
to AdWords API Forum
Thanks A Ton Dhanya for the response. It helps a lot.

for the second point, what I meant was, the response from the api gives me clicks,impressions at a keyword level where as I just need the total clicks,impressions for the campaign. how do I get this part.

I understood the other points and implemented. I am struck with the second point here.

Dhanya Sundararaju (AdWords API Team)

unread,
Feb 8, 2018, 2:31:33 PM2/8/18
to AdWords API Forum
Hi Deepesh,

Glad that they worked. In order to recreate the issue at my end so that I could troubleshoot further, could you send me your report definition and the client customer Id against which you are running the report? You may opt to reply privately to author.

lakshmana deepesh

unread,
Feb 12, 2018, 6:57:28 AM2/12/18
to AdWords API Forum
Hi Dhanya,

I have sent you the client-cutomer_ids on a private thread. please let me know if you can see the issue too.

Dhanya Sundararaju (AdWords API Team)

unread,
Feb 12, 2018, 11:31:05 AM2/12/18
to adwor...@googlegroups.com
Hi Deepesh,

I had replied to you privately on 02/09/18 14:31:45 EST. However, I will post my response here too as it has no confidential information:

Thank you for sending the requested information. In your code, I am inclined to believe that you may have used the CRITERIA_PERFORMANCE_REPORT as the fields that you have defined in your report definition, that is, AdGroupId', 'CriteriaType', 'Criteria', 'FinalUrls' are not supported with CAMPAIGN_PERFORMANCE_REPORT. The Criteria Performance Report includes statistics aggregated at the ad group criteria level, one row per ad group and criteria combination, so you will be getting multiple rows for each campaign as each campaign may have multiple ad groups and each adgroup may have multiple criteria. On the other hand, if you run the CAMPAIGN_PERFORMANCE_REPORT, you will be getting only one row per campaign, so the metrics like clicks, impressions, cost, conversions will be aggregated at the campaign level. Please let me know if you have further questions.

lakshmana deepesh

unread,
Feb 13, 2018, 5:59:21 AM2/13/18
to AdWords API Forum
Thanks a lot, Dhanya. I appreciate your response and the code works completely fine. except for a precision issue in the cost of the campaign. 

if the actual cost is 30380.040000
the api returns it as a string 30380040000.

as there is no decimal point aslo, i am unable to get the exact value of cost. this is the last piece where I am struck at. if this is solved the integration which I am planning to do will be complete.







Dhanya Sundararaju (AdWords API Team)

unread,
Feb 13, 2018, 11:52:32 AM2/13/18
to AdWords API Forum
Hi Deepesh,

The API returns cost as micro currency units. You would need to handle the conversion at your end in your code. Please refer this guide for more clarity.
Reply all
Reply to author
Forward
0 new messages