Search code examples
google-analyticsgoogle-tag-managergoogle-analytics-filters

Backwards Facing Content Grouping


Need to group some pages on my site together but apparently content grouping would only be forward facing. Is there a way to apply content grouping to prior data or create a calculated column as such which would allow GA to filter and group older data?


Solution

  • Is there a way to apply content grouping to prior data?

    No, content grouping only applies going forward.

    or create a calculated column as such which would allow GA to filter and group older data?

    No, any data you add to GA is only available as of the moment you create it.

    What you can do:


    GA:

    • Use Query Filters (not view filters) or segments: filters/segments don't create any data, they just filter it. So if you create 1 filter/segment per group and query the data, you will effectively have the same data as if you had done content grouping
    • Use Regex: GA supports regular expression which might help you create the filters you need
    • Use the API: since applying filters/segments might be tedious to do (and repeat) via the UI, you might want to use the API, for instance via the Google Sheets GA API add-on (see further details below)

    Example of Google Sheets GA API add-on query to group some content that would match all pages which start with /foo or /bar (see list of API dimensions and metrics, see legacy filters syntax):

    ga:pagePath=~^/(foo|bar)
    

    Once you have figured out 1 query for 1 group you can clone them, query all your data, and then reaggregate it.


    Google Data Studio:

    GDS has a feature called Calculated fields which effectively allows you to create content groupings which apply to both historical and new data. Most likely you want to do this with a CASE statement:

    CASE 
        WHEN REGEXP_MATCH(Page,'^/(foo|bar)') THEN "Group A" 
        WHEN REGEXP_MATCH...
        ELSE "Other" 
    END