getredash/redash · error · Exception

Can't mix mcf: and ga: metrics.

Error message

Can't mix mcf: and ga: metrics.

What it means

The GA runner splits queries between the ga: (core) and mcf: (Multi-Channel Funnels) endpoints. A single request cannot hit both, so if params['metrics'] contains both 'mcf:' and 'ga:' prefixes it raises this exception immediately after parsing the query.

Source

Thrown at redash/query_runner/google_analytics.py:168

    def test_connection(self):
        try:
            service = self._get_analytics_service()
            service.management().accounts().list().execute()
        except HttpError as e:
            # Make sure we return a more readable error to the end user
            raise Exception(e._get_reason())

    def run_query(self, query, user):
        logger.debug("Analytics is about to execute query: %s", query)
        try:
            params = json_loads(query)
        except Exception:
            query_string = parse_qs(urlparse(query).query, keep_blank_values=True)
            params = {k.replace("-", "_"): ",".join(v) for k, v in query_string.items()}

        if "mcf:" in params["metrics"] and "ga:" in params["metrics"]:
            raise Exception("Can't mix mcf: and ga: metrics.")

        if "mcf:" in params.get("dimensions", "") and "ga:" in params.get("dimensions", ""):
            raise Exception("Can't mix mcf: and ga: dimensions.")

        if "mcf:" in params["metrics"]:
            api = self._get_analytics_service().data().mcf()
        else:
            api = self._get_analytics_service().data().ga()

        if len(params) > 0:
            try:
                response = api.get(**params).execute()
                data = parse_ga_response(response)
                error = None
            except HttpError as e:
                # Make sure we return a more readable error to the end user
                error = e._get_reason()
                data = None

View on GitHub (pinned to ca79fe988d)

Solutions

  1. Split into two queries: one with only ga: metrics, one with only mcf: metrics
  2. Remove the mcf: metric if MCF data is not required

Example fix

// before
{"metrics": "ga:sessions,mcf:totalConversions", "dimensions": "ga:date"}
// after
{"metrics": "ga:sessions", "dimensions": "ga:date"}
Defensive patterns

Strategy: validation

Validate before calling

def metrics_are_consistent(metrics: str) -> bool:
    has_mcf = "mcf:" in metrics
    has_ga = "ga:" in metrics
    return not (has_mcf and has_ga)

Prevention

When it happens

Trigger: A query like {"metrics": "ga:sessions,mcf:totalConversions", ...} or URL form ?metrics=ga:sessions,mcf:totalConversions — any metrics list mixing both namespaces.

Common situations: Users combining core and MCF metrics thinking they are one API, or copy-pasting metric lists from GA UI reports that span both.

Related errors


AI-assisted analysis of getredash/redash@ca79fe988d (2026-08-28). Data as JSON: /api/errors/6ccc37725f6ac332. Report an issue: GitHub.