woocommerce / woocommerce-android

WooCommerce Android app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
276 stars 135 forks source link

[GLA Analytics] Add networking support for Google Listings & Ads analytics #11810

Closed ThomazFB closed 2 months ago

ThomazFB commented 3 months ago

We need to add support in the networking layer for the following endpoints:

Connection

Request to check if the Google Ads account is connected:

{
    "id": 1234567890,
    "currency": "USD",
    "symbol": "$",
    "status": "connected"
}

Analytics

Request for campaign analytics:

{
    "campaigns": [
        {
            "id": 123,
            "name": "One",
            "status": "enabled",
            "subtotals": {
                "sales": 11,
                "spend": 63.14
            }
        },
        {
            "id": 234,
            "name": "Two",
            "status": "enabled",
            "subtotals": {
                "sales": 0,
                "spend": 9.87
            }
        }
    ],
    "intervals": [
        {
            "interval": "2021-09",
            "subtotals": {
                "sales": 0,
                "spend": 38
            }
        },
        {
            "interval": "2021-10",
            "subtotals": {
                "sales": 11,
                "spend": 35.01
            }
        }
    ],
    "totals": {
        "sales": 11,
        "spend": 73.01
    }
}

Sample response with no campaigns (and with data envelope):

{
    "data": {
        "products": null,
        "campaigns": null,
        "intervals": null,
        "totals": {
            "sales": 0,
            "spend": 0
        },
        "next_page": null
    }
}
dangermattic commented 3 months ago

Thanks for reporting! 👍

rachelmcr commented 3 months ago

Just a note that the connection networking support is already being added here: https://github.com/wordpress-mobile/WordPress-FluxC-Android/pull/3038

rachelmcr commented 3 months ago

A couple notes about the analytics data returned by the API:

Possible campaign statuses - the status field in campaigns (from here):

Data types for each totals field (from here):