Learn business growth with Google Analytics 4 Forums Google Analytics 4 Extract pure JSON data using Google Analytics Data API v1 runReport Reply To: Extract pure JSON data using Google Analytics Data API v1 runReport

  • Matthew

    Member
    10 June 2023 at 9:11 pm

    Absolutely, let me clarify it for you.

    What you’re seeing with your $response object is an instance of GoogleAnalyticsDataV1betaRunReportResponse, which is a kind of protobuf message. This comes from Google’s approach in many APIs where they use protocol buffers for their data format.

    Because of this, you can use a method serializeToJsonString() that’s available for your response object. This method is going to generate a JSON string representation of your object.

    So, just write an echo statement echo $response->serializeToJsonString(); and this will print out your JSON string directly.