Google Analytics Custom Variables for Publishers

In the past I wrote about 5 Google Analytics custom segments for ecommerce, so it only makes sense that I return the favor for publishers!

Publishing is changing drastically. It’s all about creating a dedicated audience and providing them with good, consistent content. If you can achieve this then you’ll have a loyal, attentive audience that keeps coming back time and time again.

Many publishers usually solidify the relations with their readers through some type of membership or account structure. This is becoming increasingly important as content is now distributed through many different devices and the only way to deliver the appropriate content is by knowing who your reader is.

This progression, new reader > loyalist > member, must drive your segmentation and measurement. It’s critical to understand who these people are and what they like to read. That way you can deliver relevant content that they will enjoy.

Measuring Members with Google Analytics

That’s where custom variables come in. They let you measure more information about the interests and behaviors of your audience.

About Custom Variables

If you’ve never used custom variables before I recommend reading Mastering Custom Variables post. It will explain concepts like scope, index, and how many variables you can use.

You might also be wondering how you actually get the data into a custom variables. A lot of the information I talk about below comes from your content management system. Things like the author of an article or the date it was published.

I recommend you use some type of Data Layer to pass it from your CMS to Google Analytics. A data Layer adds key business information to each page of the site, usually in the form of a JavaScript variable or hidden HTML.

Once the data is in the data layer you can pull it into your Google Analytics custom variables.

Or you could use a plugin. Some platforms, like WordPress, have plugins that can will automatically insert the correct Google Analytics code to track this data.

Let’s move on to the actual variables!

Members & Membership ID

As mentioned above, one of the primary goals is to get loyal readers to become members. Once they become a member you need to segment this group of people from your first time visitors and your loyal readers.

You need a custom variable to segment members from non-members.

If you don’t know how many non-members are visiting the site, then how do you know your conversion opportunity?

In addition to tracking visitors who are members, I also like to track the membership ID. Some type of identifier that I can potentially use to link Google Analytics data with other data sets. This let’s me expand my understanding of my members.

I like to use a visitor scoped custom variable when identifying members. Remember, a visitor scoped custom variable is stored on a cookie on the visitors machine. It will persist from one visit to another.

_gaq.push('setCustomVar', 1, 'membID','','############',1);

It’s a good idea to trigger the code whenever a visitor logs into the site. This will push the cookie expiration date further into the future.

And don’t forget to delete the custom variable if the visitor cancels their membership. You can delete a custom variable using the following code:

_gaq.push('deleteCustomVar', 1);

Actionability: At the very least, you should know what percentage of your traffic is from members. Then you can adjust your membership conversion rate accordingly. You can also start to dig deeper into what your members really like. What type of marketing do they respond to. The most advanced thing you can do is join the Google Analytics data with other information from your membership DB, like preference information, demographics, etc.

Membership Date

Another piece of membership information that’s useful for analysis is the date the person became a member. I call this membership date. Creative, huh :)

I don’t collect the exact date, but usually the month and the year. Here’s the code for the visitor level custom variable for membership date:

_gaq.push('setCustomVar', 2, 'JoinDate','YYYYMM',1);

Sometimes, depending on how many custom variables I have available, I make the membership date part of the membership ID custom variable. I just append it to the end of the ID with a dash, or some other character, like this:

_gaq.push('setCustomVar', 1, 'membInfo','############-YYYYMM',1);

Actionability:Understanding the behavior of GROUPS of people based on date is really useful. Do people who become members in July behavior differently than those that become members in December? Do certain groups have a tendency to like certain content? Do people who sign up usually cancel their membership at some common interval?

This is commonly called Cohort Analysis. More on cohorts in an upcoming post.

Category & Sub-category

Use Google Analytics Custom Variables to categorize content.
This is probably the most common way to segment content. It’s often difficult to group content pages together using the page URL or the Page Title. Categories and sub categories are a lot easier way to roll up the data and measure performance.

You can customize this code to include as many categories as you need. But you can start with a category and sub-category.

Here’s the code for the page level custom variables for a category and a sub category:

_gaq.push('setCustomVar', 4, 'contCat','[CATEGORY NAME]',3);
_gaq.push('setCustomVar', 5, 'contSubCat','[SUB CATEGORY NAME]',3);

Actionability: Accurately measure which types of content is most engaging to your audience. Better yet, find out which members like which content, then make sure you target them with that information via email, social or on-site promotions.

If you’re using Google AdSense you can also measure revenue by content section. Cool!

Content Type

This is a bit different. Many publishers use different types of content to keep the audience engaged. Gone are the days of just publishing text articles. Now we have all sorts of things:

  • Text articles
  • Videos
  • Slideshow
  • Games
  • Quizzes

It’s a good idea to measure which types of information are most engaging to people. Perhaps you identify a certain segment of members that are really into quizzes. Then you can target them with more quizzes!

_gaq.push('setCustomVar', 5, 'contType','[Type]',3);

Tracking content type could certainly be done using the Category & Sub-category classifications. It’s really up to you and how many Google Analytics custom variables you have available.

Actionability: Very similar to measuring Categories and Sub Categories. This give publishers a way to roll the Google Analytics data up into a measurable segment.

Publication Date

Like category, Publication Date is a good way to segment your content. It’s particularly useful when trying to understand if your old content getting a lot of organic traffic. Or is it just withering away, lonely and unread? :)

I don’t think measuring the exact publication date is necessary, that’s a bit too granular. Instead I think it’s useful to measure the month and year. That’s enough to segment on.

Here’s the code for the page level custom variable:

_gaq.push('setCustomVar', 3, 'pubDate','YYYYMM',3);

Actionability: Review this segment to find which content is loosing traction and getting less traffic. Is there a way to can promote it, perhaps in social media or in a newsletter? What about refreshing it with new information?


Measuring content by author helps publishers understand which authors generate awesome content that keeps the audience engage and happy. It’s a fairly typical segmentation for any publisher. But, unless the data appears in the URL, Author is not something that Google Analytics will track.

You can collect the entire name, or initials. It’s up to you. I would consider the length of the author’s name. Remember that the custom variables name and value are limited to 128 total characters combined.

Here’s the code for the page level custom variable:

_gaq.push('setCustomVar', 4, 'author','NAME', 3);

Actionability: Work with this author to create more amazing content or hire more authors that cover this subject-matter. Or you can try to clone this author is some type of ‘author cloning machine’ :)

Readers vs. Scanners

While this is technically a visitor segment, it’s part of a bigger change publishers should implement with Google Analytics to measure people that actually read content.

I wrote two posts, Advanced Content Tracking with Google Analytics Part 1 and Advanced Content Tracking with Google Analytics Part 2, that explain how to use Event Tracking to track how people actually read an article on a publisher’s site.

This method provides a lot of really interesting data that will change the way you look at your visitors and measure your site.

Part of this code creates a segment for those that get to the bottom of the page. These people are put into a bucket called ‘readers’ meaning they actually read the article.

_gaq.push('setCustomVar', 1, 'Type','READER or SCANNER', 1);

Actionability: Ever wonder what percentage of your traffic, regardless of membership, actually READ your content? You could using these custom variables :) This data can also be segmented by the article name and type.

Don’t forget, you need to understand how to use custom variables to set this up. It’s really important to think about the index component of your custom vars. Critical!

Are there more things you could do? Absolutely. But this is some of the basic things that I think any publisher can do with Google Analytics custom variables.

Be Sociable, Share!

    Like this post? Sign up to get posts delivered to your inbox.


    1. Burak says

      Showing the top authors (based on authors posts’ unique views) would be great for multi author sites. I hope there will be a widget plugin one day :)

      Thanks for the article.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>