filter-structures
Skill244 starsChanged 43 days agoMITView on GitHub
The correct shape for `dimension_filter` in `get_ga4_data`. Wrong structure returns an \"Invalid dimension_filter\" error. Use these templates.
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Every leaf filter must be wrapped in a "filter" key.
- Very specific: line 116
If you use snake_case in fieldName, the filter will fail with an "Unknown field" error.
- Very specific: line 120
Only dimensions can be filtered with dimension_filter.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Filter Structures
The correct shape for dimension_filter in get_ga4_data.
Wrong structure returns an "Invalid dimension_filter" error. Use these templates.
The one rule
Every leaf filter must be wrapped in a "filter" key. fieldName never appears at the top level.
// WRONG — fieldName at top level
{"fieldName": "sessionSource", "stringFilter": {"value": "google"}}
// CORRECT — wrapped in "filter"
{"filter": {"fieldName": "sessionSource", "stringFilter": {"value": "google"}}}Template: single field filter
{
"filter": {
"fieldName": "DIMENSION_NAME",
"stringFilter": {
"value": "VALUE",
"matchType": "EXACT"
}
}
}matchType options: EXACT, BEGINS_WITH, ENDS_WITH, CONTAINS, FULL_REGEXP, PARTIAL_REGEXP
Template: AND — all conditions must match
{
"andGroup": {
"expressions": [
{"filter": {"fieldName": "deviceCategory", "stringFilter": {"value": "mobile", "matchType": "EXACT"}}},
{"filter": {"fieldName": "country", "stringFilter": {"value": "United States", "matchType": "EXACT"}}}
]
}
}Template: OR — any condition matches
{
"orGroup": {
"expressions": [
{"filter": {"fieldName": "sessionDefaultChannelGroup", "stringFilter": {"value": "Organic Search", "matchType": "EXACT"}}},
{"filter": {"fieldName": "sessionDefaultChannelGroup", "stringFilter": {"value": "Organic Social", "matchType": "EXACT"}}}
]
}
}Template: NOT — exclude matching sessions
{
"notExpression": {
"filter": {
"fieldName": "sessionDefaultChannelGroup",
"stringFilter": {"value": "Direct", "matchType": "EXACT"}
}
}
}Template: IN LIST — match any of several values
{
"filter": {
"fieldName": "country",
"inListFilter": {
"values": ["United States", "United Kingdom", "Canada"]
}
}
}Common wrong keys → correct keys
| Wrong key | Correct key |
and_filter | andGroup |
or_filter | orGroup |
not_filter | notExpression |
filters | expressions |
field | fieldName |
stringFilter.exact | stringFilter.value |
Field names are always camelCase
⚠️ CRITICAL FILTER TRAP: Field names in
dimension_filter(insidefieldName) MUST be exact camelCase. Passingpage_pathorsession_default_channel_groupwill fail with anUnknown field for FilterExpressionerror.
| Wrong (snake_case) | Correct (camelCase) |
page_path | pagePath |
session_default_channel_group | sessionDefaultChannelGroup |
session_source | sessionSource |
session_source_medium | sessionSourceMedium |
session_campaign_name | sessionCampaignName |
landing_page | landingPage |
device_category | deviceCategory |
event_name | eventName |
If you use snake_case in fieldName, the filter will fail with an "Unknown field" error. Do NOT retry snake_case.
Note
Only dimensions can be filtered with dimension_filter. To filter on metric
values (e.g. sessions > 100), you must do this in post-processing — the GA4
Data API does not support metric filters in RunReport.
In this repository21 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/llms-full.txtllms.txt
- docs/llms.txtllms.txt
- llms.txtllms.txt
- ga4-analyticsSkill
- ai-referral-analysisSkill
- attribution-scopeSkill
- bot-traffic-detectionSkill
- channel-acquisitionSkill
- common-metric-namesSkill
- compatible-combinationsSkill
- content-performanceSkill
- custom-dimensionsSkill
- date-rangesSkill
- ecommerce-analysisSkill
- ga4-limitationsSkill
- gcp-setupSkill
- geo-device-segmentationSkill
- gcp-setupSkill
- traffic-diagnosisSkill
- ua-to-ga4Skill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

