GA4 Syntax Help

Hello.

I am completely frustrated that the standard GA4 module forces me to write full JSON queries in order to have a scalable solution to pulling data from multiple properties. I utilized Make so I wouldn’t have to write JSON because I’m not good at it.

Would anyone in this community be able to help me troubleshoot what is wrong with the following syntax with the GA4 API? Everything seems to be working except the dimensionFilter portion.

My goal is to gather the total sessions per landing page that were referred by Pinterest. I have spent nearly a day trying all sorts of things and cannot figure this out. I have reverted the code below to match the syntax of the Input Bundle of a standard “Generate Report” GA4 block. So one would think that should work, but nonetheless, I get the following error still when placing this in a “Make an API Call” Body.

Invalid JSON payload received. Unknown name “dimensionFilter”: Proto field is not repeating, cannot start list.

Any help will be greatly appreciated!!!

{
“limit”: 10,
“metrics”: [
{
“name”: “sessions”
}
],
“dateRanges”: [
{
“startDate”: “2024-01-01”,
“endDate”: “2024-01-31”
}
],
“dimensions”: [
{
“name”: “landingPage”
},
{
“name”: “sessionSourceMedium”
}
],
“dimensionFilter”: [
[
{
“a”: “sessionSourceMedium”,
“b”: “Pinterest”,
“o”: “CONTAINS”
}
]
]
}

Here is the Input Bundle for the automated “Generate a Report” that I’m trying to emulate, but make scalable to evaluate multiple accounts…which I have been told I can only to through Make an API Call block.

Well, I tried to continue forward and I have a solution that is now working. Just thought I would share before I close it out. The dimensionFilter needed to be formatted quite differently. Code below.

{
“limit”: 10,
“metrics”: [
{
“name”: “sessions”
}
],
“dateRanges”: [
{
“startDate”: “2024-01-01”,
“endDate”: “2024-01-31”
}
],
“dimensions”: [
{
“name”: “landingPage”
},
{
“name”: “sessionSourceMedium”
}
],
“dimensionFilter”: {
“filter”:{
“fieldName”:“sessionSourceMedium”,
“stringFilter”:{
“matchType”:“CONTAINS”,
“value”:“Pinterest”
}
}
}
}

3 Likes