Learn business growth with Google Analytics 4 Forums Google Analytics 4 Troubleshooting 404 Error when Implementing GA4 in ColdFusion without Client Library Reply To: Troubleshooting 404 Error when Implementing GA4 in ColdFusion without Client Library

  • William

    Member
    3 May 2023 at 4:53 pm

    The error you’re receiving is indicating that the URL you’re trying to reach couldn’t be found on the server. The most likely cause for this is that there’s an issue with your URL construction. In the POST request, you’re adding a suffix of ‘:runReport’ to the base URL. However, according to the GA4 API documentation, ‘runReport’ should actually be part of the path, not a parameter.

    Second, when you’re assembling the JSON payload for the POST request, the JSON property names must be capitalized according to the GA4 API schema. In your code, “dateRanges”, “metrics”, and “dimensions” are all in uppercase, it should be in camelCase format as per the GA4 API.

    Lastly, check your authorization method. You’re using cfhttpparam type “formfield” to add your JSON payload, while you should use type “body” since you’re sending a JSON payload in a POST request. So rather than formfield, you would use cfhttpparam type=”body” for the JSON payload. Also ensure your content-type is set to application/json.

    Correct these issues and try again, it should work as expected. If you get further errors, make sure to check them against the details provided in the GA4 API documentation.