Googel analytic API - source and medium information based on ClientID

789 Views Asked by At

Is there any way to query the google analytics data to look for ClientID and then extract source and medium information of that client?

The scenario is, to look each clientID for x period amount of time and retrieve related info of that client like source, medium especially organic and direct, then append it to a custom URL as a parameter to pass it long between different system.

Client X -> Google API -> Source/Medium -> Website -> (Custom page with custom URL parameter + GA-source-medium-parameter) -> Next system -> Billing -> CRM (Client X - organic or Client X - Direct etc).

Is it possible on GA universal and GA4? Or it something can be setup using tag manager easily, by using cookie session or utm parameters?

PS - Not an API guy but did some decent research but couldn't locate the right info or examples.

2

There are 2 best solutions below

0
zborovskaya On

There are no standard dimension Client_ID in both API UA (https://ga-dev-tools.web.app/dimensions-metrics-explorer/) and GA4 (https://developers.google.com/analytics/devguides/reporting/data/v1/api-schema). You should create custom dimension at first and after data collecting it will be possible to query Client_ID and source/medium. But keep in mind that one Client_ID can have a few sources.

0
user19644594 On

Yes you can for UA. The dimension is called ga:clientId. For GA4, it’s available in Bigquery and is called user_pseudo_id. If you want to query it in the ga4 api, you will need to pass it as a custom user property in gtm.