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 
<adwords-api@googlegroups.com>
Sent: Wednesday, March 9, 2022 11:14 AM
To: Google Ads API and AdWords API Forum <adwords-api@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.


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)
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/<https://urldefense.com/v3/__https:/googleadsdeveloper.blogspot.com/__;!!KtbpKd1p8A!6GEZ9llVmrNnsTYL_uhrlQxAQdKgs4MRxZOnbVATIJBw4gy2VD_P8jVaPnhh2xvsnUi0CaE$>
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

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 
adwords-api@googlegroups.com<mailto:adwords-api@googlegroups.com>
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com<mailto:adwords-api+unsubscr...@googlegroups.com>
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en<https://urldefense.com/v3/__http:/groups.google.com/group/adwords-api?hl=en__;!!KtbpKd1p8A!6GEZ9llVmrNnsTYL_uhrlQxAQdKgs4MRxZOnbVATIJBw4gy2VD_P8jVaPnhh2xvsF_Ecn3Y$>
---
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+unsubscr...@googlegroups.com<mailto:adwords-api+unsubscr...@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<https://urldefense.com/v3/__https:/groups.google.com/d/msgid/adwords-api/102c65bb-6b42-4a4f-85bd-329f09cb402dn*40googlegroups.com?utm_medium=email&utm_source=footer__;JQ!!KtbpKd1p8A!6GEZ9llVmrNnsTYL_uhrlQxAQdKgs4MRxZOnbVATIJBw4gy2VD_P8jVaPnhh2xvsVJ6qWVo$>.

Best Buy Canada Ltd., 8800 Glenlyon Parkway, Burnaby, BC, Canada V5J 5K3
BestBuy.ca<https://www.bestbuy.ca/en-ca> / Privacy 
Policy<https://www.bestbuy.ca/en-ca/help/blt372c78db41358a01/blt12691f41ac6895d7>
 / Unsubscribe<https://www.bestbuy.ca/account/en-ca/email-unsubscribe>
BestBuy.ca<https://www.bestbuy.ca/fr-ca> / Politique sur la 
confidentialité<https://www.bestbuy.ca/fr-ca/aide/blt372c78db41358a01/blt12691f41ac6895d7>
 / Se désabonner<https://www.bestbuy.ca/account/fr-ca/desabonnement-courriels>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/CO6PR06MB7651B273B4CC36868E46ADA1AA119%40CO6PR06MB7651.namprd06.prod.outlook.com.
  • fa... 'srinivas satyavarapu' via Google Ads API and AdWords API Forum
    • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum
    • ... 'Satyavarapu, Srinivas - CW' via Google Ads API and AdWords API Forum

Reply via email to