Event tracking with Liferay Analytics Cloud

Liferay Analytics Cloud (Analytics Cloud) is a cloud-based SaaS offering that works with Liferay Digital Experience Platform (Liferay DXP) to give you insights into customer attributes and behavior. It aggregates your data from multiple sources and presents analytics, making it easier to understand people and their interests. 

Visitors count, session length, number of sessions, time on page, bounce rate are all great things that Analytics Cloud brings Out Of Box to you — with minimal or zero setup, but what do you do when you want to track how people are interacting with your page and contents, like click on buttons, open a modal, scroll a blog, images, etc.? 

To understand how to solve this, you first have to understand what an “Event” is.

“Events are user interactions with content that can be tracked independently from a web page or a screen load. Downloads, mobile ad clicks, gadgets, Flash elements, AJAX embedded elements, and video plays are all examples of actions you might want to track as Events.”

Event tracking leverages a custom code snippet that you add to the elements that you want to track on your page. Whenever users interact with that element, the code tells Analytics Cloud to record the event.

For instance, Blogs Entries are important content on websites, they attract readers who return to view new blog posts and interact in discussion. Analytics Cloud gives you important insights into how engaged the audience is with your blog posts, however, if you want to track when a user clicks anything within the Blog application?

This article assumes that you know a little bit about ajax and jQuery. So, let’s incorporate in your code the syntax to fire this event to Liferay Analytics Cloud, it is so simple as illustrated below:

Measure click-through rate

Analytics.send('blogClicked', 'Blog', {entryId, href, src, tagName, text, title});

In this example, the blogClicked is used to measure click-through rate or any other KPI that accounts for clicks. Some parameters are necessary to track: 

  • entryId*: An integer that represents the Blog unique ID.

  • href: The href of the blog's clicked link (only available for links).

  • src: The source of the Blog's clicked image (only available for images).

  • tagName: The tag name of the clicked HTML element.

  • text: The text of the Blog's clicked link (only available for links) or the HTML for the comment text.

  • title*: An attribute to describe any kind of asset. This information is presented in the analytics reports.

Note that parameters with * are Mandatory

But a Blog Application might send other events when a blog entry is visualized by the user, or the user scrolls the contents, or the user posts a new comment or vote in a blog.

To track it is so simple as illustrated below:

Account for traffic 

The event blogViewed is fired whenever a Blog page/entry is visualized by the user.

Analytics.send('blogViewed', 'Blog', {entryId, numberOfWords, title});

Parameters:

  • entryId*: An integer that represents the Blog unique ID.
  • numberOfWords: The number of words of the Blog post
  • title*: An attribute to describe any kind of asset. This information is presented in the analytics reports.

 

Estimate the interestingness or coverage

The event blogDepthReached is fired whenever a user scrolls the contents within the application.

Analytics.send('blogDepthReached', 'Blog', {depth, entryId, title});

Used to estimate interestingness or coverage of the content in terms of how deep into the page the user dwells.

Parameters: 

  • depth*: A number (being 25, 50, 75 or 100) representing how far the user scrolled into the blog's contents.
  • entryId*: An integer that represents the Blog unique ID.
  • title*: An attribute to describe any kind of asset. This information is presented in the analytics reports.

 

Measure interestingness or coverage by comments

The event posted is fired whenever a user posts a new comment or edit an existing one.

Analytics.send('posted', 'Comment', {className: 'com.liferay.blogs.model.BlogsEntry', classPK, commentId, title});

Parameters: 

  • classPk*: the primary key (entryId) of the asset related to the comment.
  • commentId*: the unique identifier of the comment.
  • title*: An attribute to describe any kind of asset. This information is presented in the analytics reports.

 

Measure interestingness or coverage by votes

The event Ratings is fired whenever a user votes.

Analytics.send('VOTE', 'Ratings', {className: 'com.liferay.blogs.model.BlogsEntry', classPK, ratingType: 'stars', score});

Parameters: 

  • classPk*: the primary key (entryId) of the asset related to the comment.
  • ratingType*: type of vote, currently only “stars” is supported.
  • score*: vote rating, a float ranging from 0 up to 1.

Remember that parameters with * are Mandatory

With these event tracking, you are now able to measure users’ interest in the contents of your blogs. Once you’ve set up your Analytics Cloud event tracking, you’re on your way to getting a comprehensive picture of your audience.

You’ll be able to prove the ROI of a campaign and improve features on your content to better serve your audience.