If you're an online publisher using Google Analytics, I'm sure you've heard this before: you need to use custom variables so that you can really segment and measure your audience.
You also most likely are currently working on migrating to
Google Tag Manager in order to make your life easier.
So how do you implement them together? What follows is a step-by-step
guide for installing publisher-centered custom variables using Google
Tag Manager.
I am going to assume, that you already have Google Tag Manager
installed in your site and that one of your tags is the asynch GA js. If
you don't,
read this first.
Google's Justin Cutroni recommends adding
seven custom variables for publishers. This article will go in detail and breakdown how to install four of them:
- Category
- Content Type
- Publication Date
- Author
These four custom variables at the most basic level gets you a good
idea of your overall site performance. Once you add these data points,
you can also get closer to information that other publisher-centered
analytics tools such as
Parsely track.
Let's jump in!
3 Things You Need to Know Before You Begin
- These custom variables should be implemented on the page level.
For all the custom variables mentioned above, the value changes as the
user goes from one page to the next. For example, a user might read an
article by author one and then click on a link that goes to an article
by Author 2. This is true for all the custom variables aforementioned
- You're going to need a data layer. Do not pass go, do not collect
$200. The best and only way to have these custom variables on your site
is via data layer. If you want to read more about this, here's an
article that gives a good explanation of how data layers work.
- You need the help of your front-end engineer. If you don't know this yet, you will, a good analytics person is always good to his or her front-end engineers.
Ask your front-end engineer to create a data layer that contains the
four custom variables we want to add: Content Type, Author, Category,
and Published Date. Direct them to the developer documentation on
adding data layer for Google Tag Manager. There are two key things to check in the developer implementation:
- Make sure that the data layer comes before the Google Tag Manager code (we inserted ours before the /head tag).
- I like keeping my values in small caps, this eliminates any
potential duplicate entries that could be created due to any weird
capitalizations.
Check out the way we set up the data layer in one of our sites. The
data layer in the source code for that page will look like below.
Note: pagetype is our data layer entry for content type
How to Add These Custom Variables as Values in Google Tag Manager
1. Create 4 Different Macros
You will need one for each data point that is pushed to data layer.
Below is my Author macro as an example. You will need to create one
macro each for content type, author, category, and published date.
2. Edit Your Existing Google Analytics Asynch Tag in GTM
- You don't need to create a new GA Asynch Tag.
- Add the four new custom variables in GTM based on your data layer.
- The final implementation in GA Classic Tag should look something like this, the Value is the Macros you created in step 1.
3. Create a New Version of GTM
I like to name my versions based on what changes I pushed in the version.
4. Preview Version to Make Sure the Tags and Custom Variables are Firing Correctly
I love using the preview function of GTM to check if what I
implemented will work. You can see the preview button on the top right
of every version you create in Google Tag Manager.
5. Publish the New Version of Google Tag Manager
You will start to see your new data points flow through after a few hours.
Once you have completed this setup, here are some examples of additional insights you can now access:
Isolate the Increase/Decrease in Traffic to a Specific Content Type
In the example below, I was able to drill down that it was article
content type that caused the decrease in sessions. You can now drill
down to # of articles published for the time period and get a better
understanding of what may be causing the traffic to decline.
Uncover Pages With Errors by Tracking Your 404 Pages
Uncover More Insights on the Performance of Your Authors
This is where an advanced Google Analytics implementation can get you
similar insights you have to get from signing up with other data
providers such as Parsely.
You can drill down to the number of articles, each author writes for
the month, the number of pageviews per post, and the categories each
author is writing about.
This table was derived from using data for author and published date.
This is Just the Beginning...
There are so many other possibilities of additional analysis points
once you have these custom variables set up. I'd love to hear your ideas
and get more conversations going on publisher specific Google Analytics
setups.
Article Source