-
How to implement dimension filters using GA4 APIs with Ruby?
If you’re having problems adding filters to the requests for the GA4 Custom Dimension, you’re getting multiple errors. Notably, these errors aren’t showing up when you send your requests without any filters. The issue seems to be with the syntax, which you’re finding somewhat puzzling. You’ve already looked into this documentation – https://googleapis.dev/ruby/google-api-client/v0.53.0/Google/Apis/AnalyticsreportingV4/DimensionFilterClause.html, but you’re still encountering difficulty.
Here’s the code block you’ve been using in Ruby,
{ :property=>"properties/1234", :dimensions=>[{:name=>"date"}, {:name=>"customUser:type"}], :metrics=>[{:name=>"activeUsers", :invisible=>false}], :date_ranges=>[{:start_date=>"2023-01-01", :end_date=>"today", :name=>"date"}], :order_bys=>[{:dimension=>{:dimension_name=>"date"}}], :dimension_filter_clauses=>[{:dimension_name=>"customUser:type", :expressions=>["Customer"], :not=>false, :operator=>"OR"}], :keep_empty_rows=>false, :return_property_quota=>true }
Would you be able to help identify what the correct syntax for this request should look like?
Log in to reply.