Solved

Query to get custom dimension data out of Google Analytics 4

  • 3 August 2023
  • 3 replies
  • 71 views

Badge

We currently have configured Google Analytics 4 with custom dimensions. We want to get that custom dimension out of GA4 using the CDATA Google Analytics provider with Google Analytics 4 selected. We get data out of the correct property, so everything seems to be connected right. But these are all standards reports so it seems, I want to get custom data out of it.

What should I do or what query can I use to get 1 custom dimension (customer_number), with 1 metric (event count) filtered by page_path contains 'example’ and another custom dimension (asm_user) <> 'null’?

icon

Best answer by Ankit Singh 7 August 2023, 14:57

View original

3 replies

Userlevel 4
Badge

@fab-sven  Thank you for reaching out. Custom dimensions and metrics can be queried by specifying them in a WHERE clause with the Dimensions or Metrics columns. For example, the below query can be used to retrieve a custom dimension in the Engagement view, and other filters can be added as needed.

SELECT Dimensions, Metrics, Date FROM Engagement WHERE dimensions = 'customEvent:customer_number' AND metrics = 'EventCount'

If you expect to use a certain combination of dimensions and metrics often, you can create a custom schema with the driver to generate a new view that contains these dimensions and metrics, which can be queried like any other view with the driver. Please see the link below for more information on this process.

https://cdn.cdata.com/help/DAJ/jdbc/pg_advancedqueries.htm

Badge

I want the values customer_number itself, not only in the whete clause, but also in the select. Is that possible?

Userlevel 5
Badge +1

Hey @fab-sven 

Have you tried looking at the CreateCustomSchema Stored procedure? The stored procedure should allow you to set your custom dimension and metric and create a view out of it. Subsequently, querying this newly created view should give you the results you are looking for.


To run a stored procedure, you can follow the syntax here: https://cdn.cdata.com/help/DAJ/jdbc/pg_exec.htm and specify the right input parameters to create your own custom schema for GA4 queries.

 

Can you give this a try and see if it helps?

Reply