1

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'});

1 Answer 1

4

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.

4
  • 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
    Commented Jan 23, 2020 at 19:55
  • 1
    No you don't need it when you pass content_group1 with config Commented Jan 24, 2020 at 17:29
  • If I want to send information for more than 1 content group (content_group1, content_group2...) , It is ok to do more than one call to gtag('config'? Commented Jul 16, 2021 at 15:54
  • 1
    @JorgeRamírez yes, it's fine Commented Jul 23, 2021 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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