Classify your Blog Posts in Analytics Using Content Groupings

Today we are going to go on a quest to find the scientifically-proven best blog post ever. We will do so with math.

We have a hypothesis: the best blog post ever must contain these five things:

A handful of tasteful images
A YouTube video
A length between 1200 and 1500 words
A concise title
Published on a Friday

On December 19th, Google Analytics introduced a new feature called Content Grouping. Long in the making, this feature allows analysts to combine common pages by way of Rules, URL/Title Extraction, or with a piece of JavaScript placed on those pages.

Then, just yesterday, Google Tag Manager introduced an integration with this piece of JavaScript, so that its built-in Analytics tags could define content groupings based on Rules/Macros.

And there was much rejoicing.

Our Quest

On this journey, I will show you how to classify your blog posts inside Analytics, using Google Tag Manager, so that you can see which components of your blog posts lead to the lowest bounce rates, the greatest time-on-page, and ultimately the most conversions.

(I really strongly recommend that you create a brand new View for this demo, so that if you decide you don’t like these Content Groupings you can just delete the View and not pollute your existing data! Currently there is no way to delete a content grouping once you create it!)

Step 1:

The first thing we’re going to do is log in to Google Analytics and define five content groups. Visit your Admin and look under View Settings for “Content Groups.”

The Groups will all use the “Tracking Code” configuration method. We will name the first group, “Blog Post Images“. Click “Group by Tracking Code”, select Index 1, click Done, and then click Save.

Then, rinse and repeat for all content groupings, selecting the appropriate Index for each:

Content Grouping Name

Select Index

Blog Post Images

Index 1

Blog Post Videos

Index 2

Blog Post Length

Index 3

Blog Post Title Length

Index 4

Blog Post Publish Day

Index 5

Step 2:

Now log in to Google Tag Manager and visit the container for your website. If you already have created a Universal Analytics built-in tag — or even the Traditional Analytics tag — you can use that one and skip the next paragraph.

Otherwise, we are going to create a new tag for “Universal Analytics (beta). Click on the “New” button and select “Tag”. Name the tag “Universal Analytics GATC – Blog Posts“. We need to give it the correct Tracking ID (it starts with “UA-“) from the tracking code, and choose “Page View” as the “Track Type”. We’ll also give it a Firing Rule for “All Pages” on our website, or we’ll create a rule which tells the tag to only fire on our blog… it’s up to you.

Now we’re going to take advantage of a brand new feature (added yesterday!) in Google Tag Manager which allows us to pass content groups through the built-in Analytics tag. Look under “More settings (optional)” for Content Groups, and add the following five Indexes and “Content Groups“. We’re going to be making a reference to some macros that we’ll define in a moment, using brackets {{}} to indicate a macro name.

The plain text for those macros is below:

Index

Content Group

1

{{blog post images}}

2

{{blog post videos}}

3

{{blog post length}}

4

{{blog post title length}}

5

{{blog post publish day}}

Click “Save” to save the tag.

Well done! Our quest now takes us into the strange and sometimes harrowing Land of JavaScript. But do not fear! There is light behind every shadow.

Step 3:

This step is really five steps in one: we’re going to create a new macro for each of our new content groups. Macros are Google Tag Manager’s way of pulling information off of a page, to be used in Rules and Tags. These macros are going to search through each blog post and count the number of images, number of videos, blog length and title length, and set the day of the week the post was published!

Macro #1: blog post images

We are assuming that each blog post is contained in a <div> tag with an id of “content”. (This is common with WordPress blogs.) You will need to inspect your source to ensure that this is the case for your blog. Also, we are assuming that each of our blog images have a class defined with the name “wp-image”.

Create a new macro called “blog post images“, with “Macro Type” set to “Custom JavaScript”. Then insert the following JavaScript:

Macro #5: blog post publish day

Finally, our last macro, blog post publish day will return the day of the week that the post was published! For our demo, we are going to assume that your blog post URLs have the same format as LunaMetrics’ blog posts: a URL format like 2014/01/24/. Your regular expression will be different if your URLs are set up differently.

(If the publish date is not included in your URLs, you could write a different macro to scan the page for the post date… but each situation will be different and your mileage may vary.)

Step 4:

We’re almost done. Now that we’ve created the tag and the five macros we need, we will create a new version and click “Publish”.

And now…

Our journey is almost over. Now we must wait. You can’t see content groups appear in the Real Time reports, and unfortunately your data will take a little while to populate in the new reports. For now our quest brings us pause, and reflection.

In a few hours, we can visit the All Pages report, inside Behavior > Site Content. You’ll now see that our new Content Groupings are available as a new Primary Dimension!

If our quest was successful, after a few hours, you’ll begin to see some data in these reports!

Our journey comes to an end.

You can consider the new Content Groupings essentially to be a simplified form of Content Experiments. We can examine this data, look at bounce rates, % exit rates, conversion rates, and make decisions about how to formulate our blog posts: how long should our posts be, what days should we publish, and how many images and videos should we include.

Alex Moore is our Analytics Department Manager. With a creative background, Alex started building websites from the ground up in the mid-90s. As the web matured, he shifted his focus to digital marketing, placing web analytics at the foundation of web marketing strategy. Alex has spent eight years consulting for clients, working on search engine marketing, development, web analytics and custom reporting. He also heads up our LunaMetrics training seminars across the country. The next seminar Alex will be leading will be a Google Analytics training in Seattle. Alex received his Masters degree in Ireland, where he explored the Irish coast with a furry dog and lots of pints.

Great post you’ve written about using the content grouping of Google Analytics in combination of Google Tag Manager. I will definitely take a look into it to see what kind of analysis you can do based on these values.

I think that especially the length of the blogposts can give you great insights about what works best for your readers and how far goes their attention span.

Hey, Thanks for this post. I tried making groups, wrote the macros and it was all fine until the 5 groups I made, all have the same urls in it and everything is similar. I passed an id on all my pages that I wanted to group and checked its value. The value is different for different groups, yet it shows the same urls in the group. Can you suggest something I should try? Also what is not set ?
Thanks