Custom Dimensions in Google Analytics via Google Tag Manager – Blog Categories and Dates

In this video I will show you how to create custom dimensions in Google Analytics via Google Tag Manager. I am going to use my blog posts meta data, the category and the date to create these custom dimensions. Blog categories and blog post dates are not default dimensions in Google Analytics. With a custom dimension we will be able to report on categories collective sessions as well as compare sessions between newer and older posts.

I am going to use the CSS selectors of my blog posts meta data to create a DOM Element user defined variable in Google Tag Manager. I will then use these variables to create the custom dimensions.

One very important thing to remember is to use your already existing Google Analytics pageview tag in Google Tag Manager to insert the custom dimensions. If you create a new tag this will mess up with your data, specifically Bounce Rate and Pages per Session. (sound common sense, but I have seen this mistake happen)

I am also going to create a custom report in Google Analytics with the new custom dimensions, Have in mind that it will take a day or so to start seeing data.

Follow the video for a detailed demonstration of this process.

Build an H1 (DOM Element) Variable in Google Tag Manager

There are many examples where having this type of data, the text of the H1, available will make auto events and pageview tracking easier and cleaner to report. By implementing an H1 variable I was able to simplify reporting and present a much cleaner report using the H1 test on a page instead of filtering through a large number of URLs.

H1 Variable in Google Tag Manager

Building a variable with the H1 test is actually pretty easy to do. You need to create a DOM Element variable with the following settings:
Variable name: H1
Selection method: CSS Selector
Element selector: H1

H1 Variable in Google Tag Manager

Ideally only one H1 should be present on a page. If you have multiple H1s Google Tag Manager will pick up the H1 header that appears first in the code of the page.

How to Use H1 Variable for Auto Events and Reporting

Here is how I set up an event for a client to report on the most popular service page using the H1 on the page. There are a number of ways to report on the most popular product or solution or blog post but except you are using the enhanced eCommerce that will report using the actual product name, you will use the page URL in your reports and not the name, H1, of the page.

After building the variable, build a new trigger with the following settings:
Trigger name: {Page Name} Pageview
Trigger type: Pageview
Fire on: Page URL contains {URL identifier}

H1 Variable in Google Tag Manager

Then build your auto event tag with the following settings:
Tag name: Most popular product
Tag type: Universal Analytics
Track type: Event
Event category: Most Popular Product
Event action: {{H1}}

H1 Variable in Google Tag Manager

Then select the trigger and you are all set!

You should be able to see your report under Events. Drilling down to the event action will report on the page H1 and the number of pageviews it has received for a selected period of time.