facing issues with GetReportDownloader while migrating to google adwords to ads api

338 views
Skip to first unread message

srinivas satyavarapu

unread,
Mar 9, 2022, 2:14:01 PM3/9/22
to Google Ads API and AdWords API Forum
Hi Team,

Could someone help me in below code as i am not able find exact refrence eventhough i tried using different highlighted error syntax

#from googleads import adwords
from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from datetime import date, timedelta, datetime

import math
import pandas
import argparse
import os

import locale
import sys
import _locale

_locale._getdefaultlocale = (lambda *args: ['en_US', 'UTF-8'])

def main(client):
    # Initialize appropriate service.
    #report_downloader = client.GetReportDownloader(version='v201809')
    ga_service = client.get_service("GoogleAdsService")

    # Define date ranges.
    end_date = datetime.today().strftime('%Y%m%d')
    start_date = (datetime.today() - timedelta(180)).strftime('%Y%m%d')

    # Create report query.
    report_query = (
        """
        SELECT segments.date,
        campaign.name,
        campaign.id,
        campaign.status,
        campaign.campaign_budget,
        campaign_budget.amount_micros,
        metrics.conversions,
        metrics.impressions,
        metrics.clicks,
        metrics.cost_micros,
        metrics.ctr FROM campaign
        WHERE campaign.status IN ("ENABLED","PAUSED")
        DURING {start_date}, {end_date}
        """
    )
    include_zero_impression_flag = True

    file_path = 'C:/New folder/Output Files/Adwords report pull/'
    file_name = 'MarketPlace_daily_campaign_performance_report.csv'
    f = open(os.path.join(file_path, file_name), 'wb')

    # including the SKUs with zero_impressions
    ga_service.  (report_query.format(**{'start_date': start_date, 'end_date': end_date}), 'CSV', f, skip_report_header=True,
                                             skip_column_header=False, skip_report_summary=True,
                                             include_zero_impressions=include_zero_impression_flag)
    print("Downloading to {0}......".format(os.path.join(file_path, file_name)))



if __name__ == '__main__':
  # Initialize client object.
  #adwords_client = adwords.AdWordsClient.LoadFromStorage('D:\MBB\yaml\MarketPlace_daily_access.yaml')
 googleads_client = GoogleAdsClient.load_from_storage('D:\MBB\yaml\MarketPlace_daily_access.yaml')

  main(googleads_client)

Google Ads API Forum Advisor

unread,
Mar 10, 2022, 6:55:18 AM3/10/22
to adwor...@googlegroups.com
Hi Srinivas,

Thank you for reaching out to our team.

Since it appears that you want to generate reports at campaign level, then fortunately, we have sample code for this in the Python client library. However, please note that there is no flag for the zero impression to include those data or not in the report. However, I would suggest referring to the documents below as it discussed exclusion of rows depending specific scenarios:
Zero Metrics
Selectability between segments and metrics  

Regards,
Google Logo
Ernie John
Google Ads API Team
 


ref:_00D1U1174p._5004Q2Xn0At:ref

Satyavarapu, Srinivas - CW

unread,
Mar 16, 2022, 4:16:50 PM3/16/22
to Google Ads API and AdWords API Forum

HI Team,

 

I tried modifying and executing the query based on suggested but it is giving error and I am not able to resolved.

 

My requirement is getting last 180 days of campaign performance in report. The code snippet in my program is below. Please help me in modifying the query highlighted as I have fixed all the issues and got struck.

 

end_date = datetime.today().strftime('%Y-%m-%d')
start_date = (datetime.today() - timedelta(180)).strftime('%Y-%m-%d')




query =
"""
  
SELECT segments.date, campaign.id, campaign.name, campaign.status,
    campaign.campaign_budget, campaign_budget.amount_micros,
     metrics.all_conversions, metrics.conversions,

     metrics.impressions, metrics.clicks, metrics.cost_micros,
     metrics.ctr FROM campaign

   WHERE  segments.date between ‘start_date’ and ‘ end_date’
    AND campaign.status IN ('ENABLED', 'PAUSED')
"""

 

 

 

thanks,
Srinivas

 

From: 'srinivas satyavarapu' via Google Ads API and AdWords API Forum <adwor...@googlegroups.com>
Sent: Wednesday, March 9, 2022 11:14 AM
To: Google Ads API and AdWords API Forum <adwor...@googlegroups.com>
Subject: [CAUTION! EXTERNAL] facing issues with GetReportDownloader while migrating to google adwords to ads api

 

 

This message is from an external sender and could be a phish.

Slow down, read carefully and look for signs that it may be a phish. If you think it’s malicious, click the report phish button or forward this email to phishing@bestbuy.com.

 

 

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
 
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups "Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to adwords-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/102c65bb-6b42-4a4f-85bd-329f09cb402dn%40googlegroups.com.

Best Buy Canada Ltd., 8800 Glenlyon Parkway, Burnaby, BC, Canada V5J 5K3
BestBuy.ca / Privacy Policy / Unsubscribe
BestBuy.ca / Politique sur la confidentialité / Se désabonner

Ngon Nguyen

unread,
Mar 17, 2022, 8:18:13 PM3/17/22
to ssat...@bestbuycanada.ca, Google Ads API and AdWords API Forum
Chào mừng bạn đến với bảng nhớ tạm của Gboard, bất kỳ văn bản nào bạn sao chép sẽ được lưu tại đây.Sử dụng biểu tượng chỉnh sửa để ghim, thêm hoặc xóa đoạn.Nhấn vào một đoạn để dán vào hộp văn bản.Chạm và giữ một đoạn để ghim đoạn đó. Các đoạn đã bỏ ghim sẽ bị xóa sau 1 giờ.

Vào 3:16, Th 5, 17 thg 3, 2022 'Satyavarapu, Srinivas - CW' via Google Ads API and AdWords API Forum <adwor...@googlegroups.com> đã viết:
Reply all
Reply to author
Forward
0 new messages