Search code examples
wordpressgoogle-analyticsuniversal-analytics

Google Analytics: send Content Grouping without a pageview?


I am implementing Content Grouping on my Wordpress website using the tracking code method.

I understand from the official documentation that the tracking code should be inserted before a pageview, that is,

ga('set', 'contentGroup1', 'Blog')

alone won't fire but

ga('set', 'contentGroup1', 'Blog');
ga('send', 'pageview');

will. My question is:

Is there a way to send the grouping information without relying on a pageview?

I have tried sending an event rather than a pageview, but it didn't work.

I am asking because I am using a Wordpress plugin to inject the default GA tracking code, and I would like not to mess with it.

Thank you for your time!


Solution

  • Content groupings can be applied to events, and not just pageviews. When you send in an event hit, you can go to the Events > Pages reports to see if a particular page associated with an event falls into a specific content grouping.

    One of the caveats is that the content groupings report under Site Content > All Pages report is different from the Events > Pages report. The former categorizes only pageviews, whereas the latter categorizes pages associated with an event.

    Note that if you use the 'set' method to set the content group as you've done before the pageview hit, all subsequent hits for the page (events, pageviews, transactions, etc.) will be associated with the specified content group (ie. "Blog").