googleads / googleads-python-lib

The Python client library for Google's Ads APIs
Apache License 2.0
685 stars 975 forks source link

No Data after upgrading from DFP to Ad Manager #322

Closed sudhanshu88241 closed 6 years ago

sudhanshu88241 commented 6 years ago

We have migrated from dfp to ad_manager, we are not getting report data any longer.

The report data was coming earlier for 2018-06-13 but now for same date report data is not coming. we are not sure if this is issue with library or Is it could be related to related account.

@msaniscalchi please through some pointers

msaniscalchi commented 6 years ago

Hello,

Thanks for the report! It seems unlikely at a glance that this is strictly related to the rebrand, as the underlying request should be unchanged. The rebrand largely involved the renaming of modules, classes, and other referenced to the former DFP branding.

That said, I'd like to attempt to reproduce your issue. Is it correct that you're using 14.0.0? Likewise, what version of Ad Manager are you using? Finally, what is the report you are trying to retrieve? The more information I have, the better I can attempt to replicate your issue.

Regards, Mark

sudhanshu88241 commented 6 years ago

Hi,

Thanks for response.

we are using googleads-14.0.0, using V201808 to fetch the report, API_NAME-'ad_manager' we have mainly made changes in statementbuilder() and DFP client which got replaced with AdManagerClient(),

Type of report we are trying to get is :

'reportQuery': { 'dimensions': ['DATE', 'ORDER_ID', 'ORDER_NAME', 'ADVERTISER_NAME', 'LINE_ITEM_NAME', 'AD_UNIT_NAME', 'CREATIVE_ID', 'CREATIVE_NAME'], 'dimensionAttributes': ['ORDER_TRAFFICKER', 'ORDER_START_DATE_TIME', 'ORDER_END_DATE_TIME'], 'statement': statement.ToStatement(), 'columns': ['AD_SERVER_IMPRESSIONS', 'AD_SERVER_CLICKS', 'AD_SERVER_CTR', 'AD_SERVER_CPM_AND_CPC_REVENUE', 'AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM'], 'dateRangeType': 'CUSTOM_DATE', 'startDate': report_date, 'endDate': report_date

and statement we are giving is :

(StatementBuilder() .Where('ADVERTISER_NAME = :id') .WithBindVariable('id', self.ADVERTISER_NAME) .Limit(None) # No limit or offset for reports .Offset(None))

Regards, Sudhanshu

On Thu, Sep 6, 2018 at 7:44 PM msaniscalchi notifications@github.com wrote:

Hello,

Thanks for the report! It seems unlikely at a glance that this is strictly related to the rebrand, as the underlying request should be unchanged. The rebrand largely involved the renaming of modules, classes, and other referenced to the former DFP branding.

That said, I'd like to attempt to reproduce your issue. Is it correct that you're using 14.0.0? Likewise, what version of Ad Manager are you using? Finally, what is the report you are trying to retrieve? The more information I have, the better I can attempt to replicate your issue.

Regards, Mark

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/googleads/googleads-python-lib/issues/322#issuecomment-419109146, or mute the thread https://github.com/notifications/unsubscribe-auth/AoC7nK3cRmyJSt4IacHiqXg3S-PEIx6sks5uYS3egaJpZM4Wc70z .

msaniscalchi commented 6 years ago

Hello Sudhanshu,

I've used the information you provided to make a simple example that can be run with a configurable advertiser name. I've run this against an advertiser name for which we expected to see data, and ultimately did get results. You can see the example below:

#!/usr/bin/env python
#
# Copyright 2018 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""This attempts to replicate issue 322.

https://github.com/googleads/googleads-python-lib/issues/322
"""

import argparse
import datetime
import six
import tempfile

import pytz

# Import appropriate modules from the client library.
from googleads import ad_manager
from googleads import errors

def main(client, advertiser_name):
  # Initialize a DataDownloader.
  report_downloader = client.GetDataDownloader(version='v201808')

  # Set filter statement and bind value for reportQuery.
  statement = (ad_manager.StatementBuilder()
               .Where('ADVERTISER_NAME = :id')
               .WithBindVariable('id', advertiser_name)
               .Limit(None)  # No limit or offset for reports
               .Offset(None))

  end_date = datetime.datetime.now(tz=pytz.timezone('America/New_York'))
  start_date = end_date - datetime.timedelta(days=7)

  # Create report job.
  report_job = {
      'reportQuery': {
          'dimensions': ['DATE', 'ORDER_ID', 'ORDER_NAME', 'ADVERTISER_NAME',
                         'LINE_ITEM_NAME', 'AD_UNIT_NAME', 'CREATIVE_ID',
                         'CREATIVE_NAME'],
          'dimensionAttributes': ['ORDER_TRAFFICKER', 'ORDER_START_DATE_TIME',
                                  'ORDER_END_DATE_TIME'],
          'statement': statement.ToStatement(),
          'columns': ['AD_SERVER_IMPRESSIONS', 'AD_SERVER_CLICKS',
                      'AD_SERVER_CTR', 'AD_SERVER_CPM_AND_CPC_REVENUE',
                      'AD_SERVER_WITHOUT_CPD_AVERAGE_ECPM'],
          'dateRangeType': 'CUSTOM_DATE',
          'startDate': {
              'year': start_date.year,
              'month': start_date.month,
              'day': start_date.day
          },
          'endDate': {
              'year': end_date.year,
              'month': end_date.month,
              'day': end_date.day
          },
      }
  }

  try:
    # Run the report and wait for it to finish.
    report_job_id = report_downloader.WaitForReport(report_job)
  except errors.AdManagerReportError, e:
    print 'Failed to generate report. Error was: %s' % e

  # Change to your preferred export format.
  export_format = 'CSV_DUMP'

  report_file = tempfile.NamedTemporaryFile(suffix='.csv.gz', delete=False)

  # Download report data.
  report_downloader.DownloadReportToFile(
      report_job_id, export_format, report_file)

  report_file.close()

  # Display results.
  print 'Report job with id "%s" downloaded to:\n%s' % (
      report_job_id, report_file.name)

if __name__ == '__main__':
  # Initialize client object.
  ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage()

  parser = argparse.ArgumentParser()
  # The following argument(s) should be provided to run the example.
  parser.add_argument('-a', '--advertiser_name',
                      required=True, help='The advertiser name.')
  args = parser.parse_args()

  main(ad_manager_client, args.advertiser_name)

This implies that the request is being sent and the response parsed and written to the file as expected, so I do not believe that the underlying cause of your issue is related to the client library. Instead, it likely involves your account or the advertiser name provided to the StatementBuilder. Since our domain knowledge is largely limited to the client library on this issue tracker, I recommend reaching out to the Google Ad Manager API Support Forum to troubleshoot this issue.

Of course, in the event that you do find something related to the client library in the course of troubleshooting, feel free to report back here. :-)

Regards, Mark