Introduction

Because Jive discussions, videos, documents and some other content types don’t include the place name in the content URL, you don’t have an easy way to segment or filter for all content viewed in a particular group or space. So I have been looking at capturing the place ID along the pageview.

Also, as I run an external community, we were interested in learning the proportion of people browsing as guests and logged in. This was suggested to me as a useful metric to increase the relevance of our homepage.

I therefore looked at how I could capture a bit more information to help improve the community whilst keeping my members’ privacy!

Respect Your Member Privacy

The rule in Google Analytics is very clear. You MUST NOT capture information you can assign to a particular individual. So, even if the Jive platform allowed me to save the userid, I could not save it.

That’s fine as I had absolutely no intention to spy on the members! I have been very transparent about what script runs.

Google Analytics Configuration

I needed to create 2 new Custom Dimensions to capture these two new metrics.

Google Analytics Custom Dimensions

Google Analytics Custom Dimensions

userclass

userclass as first custom dimension of the “hit” type.

userclass is saved at the same time as the pageview and its value is either

  1. guest if not logged in, or
  2. member if the reader is logged in.

placeid

userclass as second custom dimension of the “hit” type.

placeid is also saved at the same time as the pageview. It means you can see if a user logged in after seeing a piece of content for instance (it will go from one page to the same page but from guest to member).

placeid values can be:

  1. personal content: browsing content hosted on a user profile,
  2. user profile: browsing the user profile itself (URL field would give that profile username)
  3. 1: the root of the community, inbox, activity streams, actions…
  4. a number: the place identifier for spaces and groups, usually coded on 4 digits. That number can be below zero, for example on system blogs.

 

Examples on How to Use the New Dimensions

View Content Leaderboard with Place

By adding the placeid column in the content view, you can see which content and location are at the top.

In the screenshot below, you see by URL and placeid. In this example, it is obvious that DOC-7674 is in the same place as /groups/tools, so ARM and Keil Tools group.

You might choose to display the ‘Title’ field instead of ‘Page’ to get a more helpful list of threads/documents titles.

Google Analytics PlaceID in Site Content

Google Analytics PlaceID in Site Content

Create a Segment for your Community

Segmentation works to filter visits instead of views.

You can create a segment based on placeid so you learn more about the visitors who went through at least one page in your community. When you create a segment based on placeid, you will not only have pages in your place returned in the content list. This is because a segment works on the full visit. It allows you to increase your understanding of the user journey through the community.

If you want to only know about content on your page, you need to filter content based on placeid.

Google Analytics PlaceID in Segment

Google Analytics PlaceID in Segment

 

Gauge is Readers are Logged-in or are Guests

userclass new dimension was introduced to understand if readers tend to browse the community when logged in, or as guests. This can be useful to help improve landing pages, and the UI.

Google Analytics userclass on Content

Google Analytics userclass on Content

For a piece of content, you can see if readers tend to be more guests or logged in members. We expect it to be mostly guests as readers don’t need to be logged in to read the public content, even if they are members!

 

Google Analytics Tracking Code

/*Google analytics PROD*/ 
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ 
   (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), 
   m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) 
   })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); 
          var userclass; /* Either guest or logged in member */ 
          var placeid = jive.global.containerID.toString(); /* Place ID for groups, spaces, sys blogs only */ 
          if (_jive_effective_user_id < 0) { /* Variable is the userid for logged in members, or -1 for guest */
                 userclass = 'guest'; 
                 } else { 
                 userclass = 'member'; 
                 } 
          if (jive.global.containerType == '2020') {  /* Content is hosted on a profile */
              placeid = 'personal content'; 
          } else if (jive.global.containerType == '3') { /* Browsing the profile itself, not content */
              placeid = 'user profile'; 
          } 
   ga('create', 'UA-XXXXXXX-XX', 'domain.com'); /* Edit this line to put your own account details */
   ga('send', 'pageview', {'dimension1': userclass, 'dimension2': placeid}); 

From Jive 7 or 8, Cloud Communities

On Cloud, you cannot choose where you put the Google Analytics (GA) code. Unlike on Jive 6, in newer Jive platform revisions, the global variables are initialised after the GA code is called. In order for your GA code to be able to read these global variables, you must therefore delay its execution.

A possible workaround is to wait until the page is loaded to execute the Google Analytics code. You must note that this will impact your average time spent on page, as the code is executed later.
Put the code in the onload function to delay its execution:

<script>
window.onload = function () {
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
var userclass;
var userID = jive.global._jive_effective_user_id;
var placeid = jive.global.containerID.toString();
if (userID < 0) {
userclass = 'guest';
} else {
userclass = 'member';
}
ga('create', 'UA-XXXXXX-X', 'auto');
ga('set', 'dimension1', userclass);
ga('set', 'dimension2', placeid);
ga('send', 'pageview');
}
</script>

References