Open temuycro opened 7 months ago
Hi @temuycro,
dimensions should be of type Dimension. Something like [{"name": "value"}]
is expected, as an example.
dimensions=[{"name":"customEvent:click"}],
could be used in your example
Try the following
request = RunReportRequest(
property=f"properties/XXXXXXXXX",
dimensions=[{"name":"customEvent:click"}],
metrics=[{"name": "eventCount"}],
date_ranges=[{"start_date": "2020-01-01", "end_date": "today"}],
dimension_filter=FilterExpression(
filter=Filter(
field_name="hostName",
string_filter=Filter.StringFilter(value="subdomain.domain.com", match_type=Filter.StringFilter.MatchType.EXACT)
)
)
)
Please also see https://developers.google.com/analytics/devguides/reporting/data/v1/advanced#event-scoped_custom_dimensions for more examples.
Hi @parthea,
Nope, it didn't work :(
InvalidArgument: 400 Did you mean customEvent:list? Field customEvent:click is not a valid dimension. For a list of valid dimensions and metrics, see https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema
temuycro@,
I suggest you try using the API Explorer to call the getMetadata method of the Data API and make sure this dimension is available. Chances are, "click" is not among the custom event parameters available for your property. For further questions, please contact the Google Analytics API Support team, as this question does not seem to be specific to the client library implementation.
@ikuleshov hi! Thank you!
Is there a way to do this using Python?
@temuycro,
The client library was able to send the request to the API however the response from the API was
InvalidArgument: 400 Did you mean customEvent:list? Field customEvent:click is not a valid dimension
.
As mentioned in https://github.com/googleapis/google-cloud-python/issues/12466#issuecomment-2035615039, please use the Try it
method on this page to confirm that click
is among the custom event parameters available for your property. This is also mentioned in setup 1 here. Please let us know the result after querying the property.
@parthea hello.
I tried using this endpoint GET https://analyticsdata.googleapis.com/v1beta/properties/GA4_PROPERTY_ID/metadata
(changing my GA4_PROPERTY_ID with mine. But I don't know how to get the data, since my credentials is a .json file.
Sorry, I'm not a developer. I'm currently using Postman.
Would you guide me through this? Also, at least a little bit of code on Python, like the one I used in the first comment?
@temuycro , Can you try using the Try it
interface on this page https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/getMetadata?
@parthea Done! Sorry I didn't understand when you mentioned Try it
because my documentation is in Spanish lol.
You were right: the customEvent:click
is not available. Do you know why is that?
@temuycro , This is an API specific question rather than a client library question as mentioned in https://github.com/googleapis/google-cloud-python/issues/12466#issuecomment-2035615039. You'll get better quality answers from the API team. Please fill out this form to obtain technical support for the API: https://developers.google.com/analytics/devguides/support
Hello.
Whenever I want to get any Event-Scoped Custom Dimension, the API doesn't recognizes the function. I followed the syntax as showin in the official documentation, but I still get this error:
ValueError: Protocol message Dimension has no "customEvent" field.
My goal is to get the
eventCount
(number of events) from a custom event I created AND currently measuring and making reports on Looker Studio and Explorations directly on the Google Analytics 4 interface.Does anybody has the same problem?
These are the libraries I'm loading
And this is the request code: