2. Add a Document Types Collector and Characteristic - BloomReach Experience - Open Source CMS

This article covers a Hippo CMS version 12. There's an updated version available that covers our most recent release.

21-06-2018

2. Add a Document Types Collector and Characteristic

This BloomReach Experience Manager feature requires a standard or premium license. Please contact BloomReach for more information.

Previous

Include the Relevance Module in a Project

Add a Collector

The first step for adding document type views to the visitor profile is to collect the visited document types. Such data collection is done by a collector. This example uses the existing DocumentTypesCollector in the Relevance Module.

Using the Console, browse to /targeting:targeting/targeting:collectors.

Add a node documenttypes of type targeting:collector.

Add a property targeting:className to the new node with the value com.onehippo.cms7.targeting.collectors.DocumentTypesCollector.

/targeting:targeting/targeting:collectors:
  /documenttypes:
    jcr:primaryType: targeting:collector
    targeting:className: com.onehippo.cms7.targeting.collectors.DocumentTypesCollector
Note that besides using one of the existing collectors, it is also possible to develop a custom collector.

Add a Characteristic

The next step for adding document type views to the visitor profile is to add a document type characteristic. A characteristic is measurable property of a visitor, like 'the document types a visitor has seen'.

A characteristic needs some additional configuration for the backend, and some configuration and code for the frontend.

Using the Console, browse to /targeting:targeting/targeting:characteristics.

Add a node documenttype of type targeting:characteristic.

Add a property targeting:collector to the new node with value documenttypes.

Add a property targeting:scorerClassName to the new node with value com.onehippo.cms7.targeting.scoring.VectorScorer.

/targeting:targeting/targeting:characteristics:
  /documenttype:
    jcr:primaryType: targeting:characteristic
    targeting:collector: documenttypes
    targeting:scorerClassName: com.onehippo.cms7.targeting.scoring.VectorScorer

The documenttype characteristic will interpret the data collected by the documenttypes collector. The scorer calculates how well certain collected data matches with a document type target group.

View the Collected Data

The collected data can be viewed via the Relevance Module's REST service:

  1. Log into the CMS

    Without logging into the CMS first, you'll get an 'HTTP Status 500' message from Tomcat. Logging in will authorize the REST mount.
  2. In a new tab in the same browser open the following URL:

    http://localhost:8080/site/_targeting/visitors

    The JSON response will be fairly empty as there have not been any visitors to the site yet (count: 0):

    {
      success: true,
      message: null,
      data: {
        items: [ ],
        count: 0
      },
      errorCode: null
    }
  3. In another browser tab browse to the home page of the site:

    http://localhost:8080/site
    

    and browse to a news article, e.g.

    http://localhost:8080/site/news/2015/08/the-medusa-news.html
  4. Go back to the tab in which you requested the REST service. Refresh the response and locate the visitor ID of your browser in the JSON output (in the example 'd6a654c1-d858-4617-8525-5c6c45779232'):

    {
      success: true,
      message: null,
      data: {
        items: [
          {
            id: "d6a654c1-d858-4617-8525-5c6c45779232",
            country: "",
            segment: null,
            lastActionTime: "2016-06-13T11:53:17.392-0700",
            latitude: 0,
            longitude: 0
          }
        ],
        count: 1
      },
      errorCode: null
    }
    
  5. See how the 'documenttypes' collector collects the document types in the REST output of that visitor at:

    http://localhost:8080/site/_targeting/visitors/d6a654c1-d858-4617-8525-5c6c45779232/details
    
    {
      success: true,
      message: null,
      data: {
        id: "d6a654c1-d858-4617-8525-5c6c45779232",
        targetingData: {
          geo: {
            collectorId: "geo",
            city: "",
            country: "",
            latitude: 0,
            longitude: 0
          },
          documenttypes: {
            collectorId: "documenttypes",
            termFreq: {
              myhippoproject:newsdocument: 1
            },
            size: 100
          }
        },
        personaScores: [ ],
        lastActionTime: "2016-06-13T11:53:17.392-0700"
      },
      errorCode: null
    }

Since the news article page is backed by a myhippoproject:newsdocument, the REST output of the visitor should now show that the visitor has seen ' myhippoproject:newsdocument' once.

Tip: add a browser extension to nicely format JSON output. For example, the 'JSONView' extension available for Chrome and Firefox.

In the CMS

The list of characteristics in the Characteristics tab of the Audiences perspective in the CMS will now contain an additional entry 'documenttype' (make sure to first refresh the CMS UI in your browser). However, we would like to have a nicer description there like "has seen (document type)", and a nice editor for the target groups, etc. That's all taken care of in the next step.

Next

Add a Document Type Characteristic UI Plugin

Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?