Segmenting Data Correctly

30 views
Skip to first unread message

Moss Adams Data

unread,
Sep 29, 2022, 6:21:48 PM9/29/22
to Google Ads API and AdWords API Forum
Hello,

I have this Python function to call a basic campaign statistics report.

def main3(client, customer_id):
    ga_service = client.get_service("GoogleAdsService")

    query = """
        SELECT campaign.id, campaign.name, ad_group.id, metrics.impressions, metrics.clicks, metrics.cost_micros,
        metrics.conversions, metrics.impressions, segments.date, ad_group.name, metrics.view_through_conversions
        FROM ad_group
        WHERE segments.date BETWEEN '2017-05-15' AND '2022-09-28' """

    # Issues a search request using streaming.
    stream = ga_service.search_stream(customer_id=customer_id, query=query)
    data_dict = {}
    for batch in stream:
        for row in batch.results:
            data_dict.update({row.segments.date: {"Campaign Name": row.campaign.name,
                              "clicks": row.metrics.clicks,
                              "conversions": row.metrics.conversions,
                              "costs": row.metrics.cost_micros ,
                              "impressions": row.metrics.impressions,
                                "ad group": row.ad_group.name,
                             "View Through Conv": row.metrics.view_through_conversions}})
    return data_dict

The data that it returns though is not correct because on the old AdWords API, there is data as shown in the first picture. Google Ads 1.png
But the new call that I have returns info like the second picture.
Google Ads 2.png

There is a whole month/date of information missing. How do I change the API call to give me the right segmentation?

Thanks.

Google Ads API Forum Advisor

unread,
Sep 30, 2022, 1:13:59 PM9/30/22
to bsgmanagemen...@mossadams.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to our API support team.

If you wish to segment by month, the segments.month or segments.month_of_year can also be included in your query. 

However, for our team to take a closer look, and since you are comparing the old AdWords API query and Google Ads API query, could you share to our team as well the old and exact AWQL you used that returned the information as seen in the first image/picture?

In addition, could you share your Google Ads account / customer ID in which these reports were generated for?

 You can opt to continue this discussion privately using the Reply privately to author option, and provide there the requested information. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.

Best regards,

Google Logo
Peter Laurence
Google Ads API Team
 


ref:_00D1U1174p._5004Q2ev4td:ref
Reply all
Reply to author
Forward
0 new messages