Learn business growth with Google Analytics 4 Forums Google Analytics 4 Session Conversion Rate and Conversion Name with Spaces

  • Session Conversion Rate and Conversion Name with Spaces

    Posted by Madison on 12 April 2023 at 6:02 am

    So I’m scratching my head a bit on this one. I’ve been smoothly sailing along getting sessionConversionRate for a variety of conversions using GA4 Data API. It’s all smooth sailing as long as the request metric looks like sessionConversionRate:conversionName.
    Now I have a customer (unfortunately I don’t have direct access to their GA4 account) who has named their conversions like conversion with space. So, naturally, I fire off a request for the metric sessionConversionRate:conversion with space… and, boom, error:

    Metric names must only contain letters, numbers, or _. Received a metric name = session_conversion_rate[conversion with space]
    

    No worries, I thought, I’ll just replace the space with underscore. Problem solved, right? Wrong. I try that and end up with another error message:

    Did you mean sessionConversionRate:conversion with space? Field sessionConversionRate:conversion_with_space is not a valid metric.  For a list of valid dimensions and metrics, see https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema
    

    So, here I am, ringing the bell for help. Is there a magic trick or workaround I’m missing here?

    Nguyen replied 11 months, 2 weeks ago 3 Members · 2 Replies
  • 2 Replies
  • Charlie

    Member
    27 June 2023 at 2:40 am

    In Google Analytics 4, metric names in namespaced forms must comply with the following rules: they cannot have spaces in them and only special characters allowed are underscore (_) and period (.). The error seems likely because the GA4 API is not able to parse the conversion name when it contains space. Unfortunately, the API does not support conversion names with spaces, so you can’t replace space with any other special characters in a conversion name. The best way to handle this situation would be to rename the conversions in the GA4 interface to not include spaces. You can suggest to your customer to rename their conversions without spaces, it would be something like “conversion_with_space” instead of “conversion with space”. Following these naming rules should solve the issue you are facing.

  • Nguyen

    Member
    4 July 2023 at 5:15 am

    It seems like you’re encountering issues with Google Analytics 4 Data API due to conversions named with spaces. The error messages indicate that a metric name should only contain letters, numbers, or underscores. When spaces in the conversion names were replaced with underscores, another error occurred suggesting that the metric doesn’t exist. Unfortunately, without access to the GA4 account in question, it can be challenging to pinpoint the exact problem. It may be helpful to work with the customer to rename their conversions using only letters, numbers, or underscores to satisfy the naming rules. Alternatively, it’s also worth exploring whether the API provides a way to handle or encode spaces in the conversion names.

Log in to reply.