Hi class, gather round, I’m your teacher and today we’re going to do a class project. Together, we will learn about custom dimensions – a kind of custom variable in Google Analytics.

You will need:

  • A website running Universal Analytics (analytics.js)
  • A Google Analytics account
  • Some data that you would like to import into Google Analytics
  • A web developer (optional, it depends on how your website is configured – I needed one)
  • Google Tag Manager (optional, but this project uses it – there are resources at the bottom if you choose not to use Google Tag Manager)

Once you have all of these things, follow the instructions below.

Our project: Creating an author report in Google Analytics

Or “How to show your boss that your blog posts are adding value to the business”.

At the minute, I have to do all of these things:

  1. Go into Google Analytics
  2. Go into the relevant content report
  3. Search for all blogs that relate to me
  4. Aggregate data
  5. Show my boss that my blog posts are amazing

Step three and four can be very tough/time-consuming if your blog isn’t in a format like www.example.com/blog/author/firstname-lastname/amazing-blog-post/

Even if it is in this format, you still have to perform a search for /firstname-lastname/.

But, with “author” being imported as a custom dimension, we could simplify this to:

  1. Go into Google Analytics
  2. Go into the “Authors” report
  3. Show my boss that my blog posts are amazing

So, that’s what our project is going to be.

Custom Dimensions: A step-by-step project guide

Step One – Determine what variables you want to import

I have decided I want to import “Author” as a custom dimension.

Emma Barnes Author Bio

Step Two – Custom Dimension configuration

We must decide the following things:

  • Name – the name of the custom dimension as it will appear in your reports. That will be “Author”
  • Scope specifies which data from the custom dimension or metric will be applied.  We want to apply “Author” to any pages with an author (i.e. on the ”pageview”, which is a ”hit” rather than the overall session) so in this instance we choose “hit”
  • Active whether the custom dimension or metric value will be processed. Inactive custom dimensions may still appear in reporting, but their values will not be processed. Yes, we would like these to be “active”, so this value should be set to “true”

Once they have been decided upon, venture into the “Admin” section in Google Analytics.

We have to be in Admin>Properties>Custom Variables>Custom Dimensions

 Custom Dimensions

Then, clickNew Custom Dimension.

After that, set your scope:

Author Custom Dimension

Step Three – Take note of your Custom Dimension number

Once you have completed Step Two, you will get given some code like this:

var dimensionValue = ‘SOME_DIMENSION_VALUE’;

ga(‘set’, ‘dimension1‘, dimensionValue);

Take note of the number of your dimension; in this case 1.

Step Four – Create a User-Defined Variable in Google Tag Manager

Log into Google Tag Manager and select “Variables” from the left-hand side.

Custom Vairables

Scroll down to “User Defined Variables” and create a brand new one and call it “Author”.

User Defined Variables

Here is the part where you summon a developer!

I don’t do development, so that’s what our Dev team is for. Ask them very kindly “can you create a Data Layer Variable to pull in author for blog posts”. You can even link them to some of the resources I’ve listed below. Once they have done that, make sure to ask them for the Data Layer Variable Name.

You can check this by using a plugin. I use James Analytics/SEO Auditor.

James Data Layer Inspector

In this case the Data Layer Variable name is “author”.

Thank you developer, back to Google Tag Manager

We were in the middle of creating a Custom Variable. Select variable type “Data Layer Variable”.

Tag Manager Data Layer Variable

And tell it that you want to use the data layer variable called “author”.

data layer varaible author

Click “Create Variable” and we’re almost done.

Step Five – Amend your Universal Analytics tracking tag

Now, select “Tags” from the left-hand side.

tags in tag manager

Then, find your Universal Analytics tracking tag:

universal analytics tracking tag

Click it and then click “edit” on “Configure Tag”.

Under “More settings”, open up “Custom Dimensions” and add the index number (from Step Three) into “Index” and select “Author” by clicking the “Variable” button beside the “Dimension Value”  field.

Author Tag

With this in place, you are ready to save your tag!

save tag

Step Six – Create and publish your changes

Once your tag is amended and changed, go to the top-right of your tag manger account and click “Publish”.

publish changes

Now, Google Analytics begins to pull in Author info.

Creating your custom “Author” Report

To view this wonderful new data, you need to create a custom report. I wrote a whole blog post about custom reports in case you get stuck.

TL;DR: Click Customisation>New Custom Report.

Here is my configuration:

Name: Blog Authors

Metrics: Pageviews, Avg. Time on Page, Page Value (choose whatever is valuable to you/makes sense – I am effectively treating “author” as a group of pages so chose some that relate to pages. Read more about metrics in GA here)

Dimensions: Author (this is our brand new dimension!)>Page (if you want to see individual pages)

Filter: Exclude Author Exact null (this gets rids of any pages that don’t have authors assigned to them)

Save your Author Report!

The Final Product:

Emmas Blog Posts are Great

After 24 hours, you should be able to see your brand new author info in this report! That is really cool!
With this data I was able to prove that my blog posts were both more popular and more valuable than the CEO’s blog posts so that’ll either get me in his good book or his bad book.

Potential Custom Dimension Pitfalls

There were two problems I ran into when trying to create this report. I’ve detailed them here so you can avoid them.

  • Only sometimes grabbing the Author name – This may happen if you’re using the DOM to extract the author rather than the Data Layer. This can work, but may not. Often, the Google Tag Manager code would launch earlier than the DOM Element, and the “Author” would not always generate within Google Analytics. There are a few ways to fix this such as launching the GA code on DOM-ready (would not recommend as it may not record all visits) or adjusting the tag firing priority, but using the Data Layer seemed like a more viable solution.
  • Author recording for incorrect pages – This will happen if you set the “scope” to “session” rather than “hit”. It will assign every visit the author in the same way each visit is assigned a source or medium. For the purposes of this case study ”scope” should be set to “Hit”.
  • Author recording for non-authored – Check your Data Layer Implementation, it may be firing on pages that have an author within WordPress, but they shouldn’t be recording within Google Analytics.

Other resources

Here are a list of resources that cover in detail how to create a custom dimension. There are a lot of ways to do it depending on how your website is configured, so some of these may be able to help you if a different method is required.

Creating a Custom Variable: https://support.google.com/analytics/answer/2709828?hl=en

Developer Guide: https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets

Within Google Tag Manager: https://support.google.com/analytics/answer/6164990?hl=en

Creating a Data Layer: http://www.optimizesmart.com/google-tag-manager-data-layer-explained-like-never/

Using the DOM Element: http://www.simoahava.com/analytics/macro-guide-google-tag-manager/#13

If you need some help, we offer analytics training as well as consultation.

Related Posts