I am trying to separate my site pages using "content group" in google analytics. So that I track how different page titles perform. I don't know which of these two is the right way to modify html code to track each group.

Do I use what I see under admin > property > view > content grouping ?

gtag('set', {'content_group1': 'My Group Name'});

OR what I see at https://support.google.com/analytics/answer/2853546?hl=en&utm_id=adcode

gtag('config', 'GA_TRACKING_ID', {'content_group1': 'My Group Name'});

Content group passed with set command will be added to the next hit, like:

gtag('set', {'content_group1': 'My Group Name'}); \\ No data sent

gtag('event', <action>, {                 \\ Now data will  include content group
  'event_category': <category>,
  'event_label': <label>,
  'value': <value>

Usually you'd want to have it sent with the first page view hit so gtag('config', 'GA_TRACKING_ID', {'content_group1': 'My Group Name'}); would work fine for you.

| improve this answer | |
  • Thanks, so if I use it like this, then I don't need the set and event ? gtag('config', 'GA_TRACKING_ID', {'content_group1': 'My Group Name'}); – adrianTNT Jan 23 at 19:55
  • No you don't need it when you pass content_group1 with config – Дмитро Булах Jan 24 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.