Using Google Analytics to understand the performance of your blog or articles

A Practical Guide to Data-Driven Blogs

Writing a blog or articles for your website can be an important part of any content marketing strategy. However, if you're like us, just writing your blog isn't good enough, you also need to know how it is performing and what its return on investment is for your website. Now, at an individual level, this is easy in Google Analytics, but it can be a lot harder to get the higher-level view on how different types of content are performing on your site. In this article, HammaJack co-founder Jacob Moran outlines how HammaJack tracks the performance and value of their articles.

A Caveat

The below will be tracking a Squarespace blog (as that is what our site is built on) but with a few small tweaks, you could easily use it for any Content Management System (CMS), like WordPress, Wix, Weebly or your CMS of choice.

We are also using Google Tag Manager as it makes all of this a lot easier but it’s also possible with an on-page Google Analytics implementation.

Categories and Tags

Most CMSs have some sort of categories and tags content categorisation protocol that is designed so you can classify your posts based on what they are about. Generally, categories are higher-level descriptions and tags are their children.

If you want to learn more about how they work, take a look an article about how we use tags and categories.

Using categories we can easily classify our posts in Google Analytics to see how they perform at high-level. It’s just another way that we are able to glean additional insights about what type of content is driving actions. So, how do we do it?

Pushing the Categories to the DataLayer

The first step is getting the categories into the DataLayer so that Google Tag Manager can use them. If you aren’t familiar with the DataLayer or Google Tag Manager — check this out.

After this is completed, we can scrape the category HTML output on the post itself. In Squarespace, we can do this by injecting code into each blog post that looks for innerHTML of the class that has the category in it and then push it to the DataLayer. The below code achieves this;

var Category =".blog-item-title .blog-category"), 
    function (element) { return element.innerHTML })

  dataLayer.push ({
    'CombinedCategory': Category.join (', '),
    'ArticleCategoryPrimary': Category [0],
    'event' : 'CategoriesOfArticle'

So what does this all do? In short, we make the innerHTML of the categories’ Class a variable and then we push the variable in two forms to the Datalayer using datalayer.push. See the screenshot for more details.

Example - Script in Squarespace.png

At HammaJack, we define a primary category that we use to define what the article is primarily about. We capture it separately and then we also capture all of the post’s categories together.  

The main reason for this is so we can avoid multiple categories causing multiple records in Google Analytics that would occur if we captured all of the categories individually.

For example, if tracked categories individually and we had a post with the categories of “Holiday” and “Gifts” that was then split into individual categories in Google Analytics it would lead to having a view for “Holidays” and a view for “Gifts” even though the user only saw the post once.

Capturing in Google Tag Manager

Now that we have the categories in the DataLayer we need to push it to Google Analytics. To do that we need to create some DataLayer Variables in our Google Tag Manager container.

To do this simply head to the Variable’s section of GTM and make them look like the screenshot. The variables we need to create are the same ones that we just declared in the script in Squarespace.

Example - Categories DataLayer Variable.png

As a recap they are:

  • CategoriesOfArticle

  • ArticleCategoryPrimary

  • CombinedCategory

Once this is done, preview the container and you should see them being presented as DataLayer variables.

Example - Categories in the DataLayer.png

Setting it up in Google Analytics

After this, we need to head over to Google Analytics and configure it to show our data. In Google Analytics we use a combination of Content Groupings for the Primary Article Category and a Custom Dimension for the Combined Categories.

We find this approach is better than other approaches out there because it allows us to see the data by either a single category or if we prefer, the category combination without inflating our hits.

Setup the Content Group

If you aren’t familiar with Content Groups - check out the official GA help section, but basically you have Content Groupings and then under them, you have Content Groups (yes they could/should have picked more unique names).

For our purposes we are going to create a Content Grouping called “Articles” and then enable the “Enable Tracking Code” option.


Example - Content Groupings.png

Now, we don’t need to create any Content Groups under it at this stage, because we are going to do that programmatically later through GTM.

Setup the Custom Dimension

Again, if you aren’t familiar with Custom Dimensions - check out the official GA help section.

What we need to do here is track a hit level Custom Dimension that captures all of the combined categories.


Again we just need to set it up in Google Analytics and then GTM will take care of the rest.

Edit the Google Analytics Tag in Google Tag Manager

Head back to GTM and go into your Google Analytics Tag. If you are using the GTM GA template tag then the next bit is easy, if you’re not, it’s still pretty easy but you’ll need to do some minor coding.

If you are using the template all you need to do is assign the Custom Dimension and Content Group to the slots you just got from Google Analytics (in the screenshots above it is slot 1) and then assign values to the DataLayer Variables you created earlier. It should end up looking like the screenshot.

Example - GTM GA Tag.png

The last step here is to change the Firing Trigger to when the DOM is Ready. The reason for this is that we need to give time for our Squarespace Script to declare what the categories are before we fire the Google Analytics tag that is looking for them.

As a side note, DOM Ready seems to be long enough for our site to declare the categories, but it isn’t foolproof - if you want something that will definitely hold off your GA tag from firing until the categories are present you can implement an eventCallback.

Viewing the Data

Once you’ve tested and published this it’s time to sit back and let the data roll in. After a few days, you should start to see the fruits of your labour. This is the cool part.

Because we’ve captured the primary category by itself we can get a nice and clean view of how each Content Group (category) is performing. You can see this view by changing the Content Grouping to Articles under the Behaviour > Site Content Reports.  


Importantly if you are keen on assessing the value of your articles and your goals in Google Analytic have values attached to them you can start to, at a Macro level, assign an actual value to your blog. This will allow you to see the types of content that perform best for conversion and also what content users find the most useful. As you can see our demo account is showing there is no value in our articles for this reporting period (maybe we should invest in a Super Bowl commercial instead?).

However, if you’re like me, you’ll want to really drill down into how different category combinations perform. Luckily this is also being tracked so that you can slice the data this way if you want.

There are a few options available for viewing custom dimensions but here at HammaJack, our favourite is generally Custom Reports.


Once you’ve been tracking this for a while, it opens up all kinds of opportunities and you can start to do all kinds of analysis.

Most Important Point

If you only take one thing away from this article make it this:

Articles and blogs can be a super important part of your business, but they need to be analysed to understand their effectiveness and whether they are getting a good enough ROI. This can be very difficult at a higher level if you write a lot. Using the above solution for categories (or expanding it to tags as well), allows you to see the value forest for the trees.