Learn business growth with Google Analytics 4 › Forums › Google Analytics 4 › How to combine andGroup and notExpression in GA4 filter json syntax? › Reply To: How to combine andGroup and notExpression in GA4 filter json syntax?
-
Absolutely! Here’s an easy-going way to create a JSON for GA4 filters with andGroup and notExpression. Just remember, you want to match “field1” and not match “field2”. The syntax would look like this:
`json
{
“andGroup”: {
“expressions”: [
{
“filter”: {
“fieldName”: “field1”,
“stringFilter”: {
“matchType”: “EXACT”,
“value”: “match_me”
}
}
},
{
“notExpression”: {
“filter”: {
“fieldName”: “field2”,
“stringFilter”: {
“matchType”: “EXACT”,
“value”: “do_not_match_me”
}
}
}
}
]
}
}
`
Relax, it’s not as complicated as it looks! In the first expression, we’re matching “field1” with “match_me”. In the second, we’re saying “do_not_match_me” to “field2”. Both of these expressions are grouped under “andGroup”. Keep practicing and you’ll soon get the hang of it!