# Query to get custom dimension data out of Google Analytics 4

**URL:** <https://community.cdata.com/t/query-to-get-custom-dimension-data-out-of-google-analytics-4/309>\
**Category:** CData Drivers\
**Tags:** question, driver, connector, googleanalytics4\
**Created:** [August 3, 2023, 12:34pm UTC](https://community.cdata.com/t/query-to-get-custom-dimension-data-out-of-google-analytics-4/309 "2023-08-03T12:34:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fab-sven](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@fab-sven](https://community.cdata.com/u/fab-sven)\
**Post date:** [August 3, 2023, 12:34pm UTC](https://community.cdata.com/t/query-to-get-custom-dimension-data-out-of-google-analytics-4/309/1 "2023-08-03T12:34:40Z")

</div>

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&nbsp;contains 'example’ and another custom dimension (asm\_user) \<\> 'null’?

---

<div class="post-metadata">

**Author:** ![Elizabeth\_G](https://avatars.discourse-cdn.com/v4/letter/e/6bbea6/32.png) [@Elizabeth\_G](https://community.cdata.com/u/Elizabeth_G)\
**Post date:** [August 4, 2023, 6:21pm UTC](https://community.cdata.com/t/query-to-get-custom-dimension-data-out-of-google-analytics-4/309/2 "2023-08-04T18:21:14Z")

</div>

@fab-sven &nbsp; 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.

> **[CData Software - Online Help Files](https://www.cdata.com/kb/help/)**

---

<div class="post-metadata">

**Author:** ![fab-sven](https://avatars.discourse-cdn.com/v4/letter/f/82dd89/32.png) [@fab-sven](https://community.cdata.com/u/fab-sven)\
**Post date:** [August 4, 2023, 6:53pm UTC](https://community.cdata.com/t/query-to-get-custom-dimension-data-out-of-google-analytics-4/309/3 "2023-08-04T18:53:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ankit\_Singh](https://sea3.discourse-cdn.com/cdata/user_avatar/community.cdata.com/ankit_singh/32/1614_2.png) [@Ankit\_Singh](https://community.cdata.com/u/Ankit_Singh)\
**Post date:** [August 7, 2023, 12:57pm UTC](https://community.cdata.com/t/query-to-get-custom-dimension-data-out-of-google-analytics-4/309/4 "2023-08-07T12:57:29Z")

</div>

Hey @fab-sven

Have you tried looking at the [CreateCustomSchema](https://cdn.cdata.com/help/DAJ/jdbc/pg_GoogleAnalytics4sp-createcustomschema.htm) 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:&nbsp;[CData JDBC Driver for Google Analytics - EXECUTE Statements](https://cdn.cdata.com/help/DAJ/jdbc/pg_exec.htm)&nbsp;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?
