GA4 compare
ga4_compareCompare a GA4 period with an earlier one in ONE call (Data API runReport with two date ranges): this month against last month, the last 7 days against the 7 before, a month against the same month last year.
Instructions
Compare a GA4 period with an earlier one in ONE call (Data API runReport with two date ranges): this month against last month, the last 7 days against the 7 before, a month against the same month last year. Returns, per row, the current and previous value of each metric with the absolute "change" and "change_pct" (percent; None when the previous value is 0), "totals" over every row, the unit and definition of each metric under "metrics", the currency, both "date_range"s resolved to calendar dates in the property's timezone with "data_complete", and "biggest_moves": the 5 rows whose first metric changed the most in absolute terms. A key present in one range only shows the other as 0 and a "present_in" list. Use ga4_report for a single range.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum rows returned (1 to 1000); totals and biggest_moves always cover every fetched row | |
| period | No | last_7_days, last_14_days, last_28_days, last_30_days, last_90_days, this_month (month to date, up to yesterday), last_month (whole previous month) or YYYY-MM-DD:YYYY-MM-DD | last_28_days |
| metrics | No | GA4 API metric names, e.g. sessions, purchaseRevenue, ecommercePurchases; the first one ranks biggest_moves | |
| client_id | No | Client id from clients_list. Required when several clients are registered; empty uses the only client (or the environment variables when there is no client registry) | |
| compare_to | No | previous_period: the range of the same length just before (this_month is set against the same number of days of the month before); previous_year: the same dates one year earlier | previous_period |
| dimensions | No | GA4 API dimension names that split the rows, e.g. sessionDefaultChannelGroup, landingPage, itemName; empty list for one row of totals | |
| property_id | No | Numeric GA4 property id, as listed by ga4_properties; empty uses the configured GA4_PROPERTY_ID (or the client's property) |