Analytics
3.9K members online now
Understand information in your reports and troubleshoot reporting issues such as self-referrals, (not set) data, and inaccurate information
 
Guide Me
star_border
Reply

How to filter ga:adTargetingType dimension in Core Reporting API?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

 

I'm having difficulties filtering by the ga:adTargetingType dimension. I'm trying to get some metrics grouped by Campaign, AdGroup and Criteria ID, just for a specific account. On top of that I also want to include only those Criteria ID which have a ga:adTargetingType set to "Keyword". 

 

I came up with the following query body for the API python client:

 

        return analytics.reports().batchGet(
            body={"reportRequests": [{
                "pageSize": 10000,
                "viewId": VIEW_ID,
                "dateRanges": [
                    {"startDate": "31daysAgo", "endDate": "yesterday"}
                ],
                "dimensions": [
                    {"name": "ga:adwordsCampaignID"},
                    {"name": "ga:adwordsAdGroupID"},
                    {"name": "ga:adwordsCriteriaID"}
                ],
                "metrics": [
                    {"expression": "ga:adClicks"},
                    {"expression": "ga:adCost"},
                    {"expression": "ga:uniquePurchases"},
                    {"expression": "ga:itemRevenue"},
                    {"expression": "ga:CPC"},
                    {"expression": "ga:ROAS"}
                ],
                "dimensionFilterClauses": [
                    {"filters": [
                        {"dimensionName": "ga:adwordsCustomerID",
                         "operator": "EXACT",
                         "expressions": ["2096809090"]}
                    ]}
                ],
                "metricFilterClauses": [
                    {"filters": [
                        {"metricName": "ga:adCost",
                         "operator": "GREATER_THAN",
                         "comparisonValue": "0"}
                    ]}
                ],
                "orderBys": [
                    {"fieldName": "ga:adClicks",
                     "sortOrder": "DESCENDING"}
                ]}
            ]}
        ).execute()

Hi however returns a "Status 400: Bad Request", due to the ga:adTargetingType filter. If I remove it or change it to another kind of filter, the query works as expected. This makes me thing I might have been using the wrong operator or parameter to set such filter. 

 

I'm sure the filter should return some results since I can use in the Query Explorer as "ga:adTargetingType==Keyword".