2. Add a Document Types Collector and Characteristic

Important: This feature in Bloomreach Content requires a standard or premium license. Contact Bloomreach for licensing details.

Previous

Include the Relevance Module in a Project

Add a Collector

To track which document types visitors view, configure a collector to record this data in the visitor profile. Collectors gather specific information about visitors. In this example, use the existing DocumentTypesCollector provided by the Relevance Module.

  1. Open the Console.
  2. Navigate to /targeting:targeting/targeting:collectors.
  3. Add a node named documenttypes of type targeting:collector.
  4. Set the property targeting:className on the new node to com.onehippo.cms7.targeting.collectors.DocumentTypesCollector.
/targeting:targeting/targeting:collectors: /documenttypes: jcr:primaryType: targeting:collector targeting:className: com.onehippo.cms7.targeting.collectors.DocumentTypesCollector

Note: You can use one of the existing collectors or develop a custom collector if your requirements differ.

Add a Characteristic

Next, add a document type characteristic to the visitor profile. A characteristic represents a measurable property of a visitor, such as the document types they have viewed.

This step requires configuration in both the backend and, later, the frontend.

  1. In the Console, go to /targeting:targeting/targeting:characteristics.
  2. Add a node named documenttype of type targeting:characteristic.
  3. Set the property targeting:collector to documenttypes.
  4. Set the property targeting:scorerClassName to 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 uses data from the documenttypes collector. The scorer evaluates how closely a visitor’s collected data matches the criteria for a document type target group.

View the Collected Data

You can verify the collected data using the Relevance Module's REST service:

  1. Log in to the CMS.

    Note: You must log in to the CMS before accessing the REST endpoint. Otherwise, Tomcat will return an 'HTTP Status 500' error.

  2. In a new browser tab, open:

    http://localhost:8080/cms/_targeting/visitors
    

    The initial JSON response will be empty if there have been no visitors (count: 0):

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

    http://localhost:8080/site
    

    Then navigate to a news article, for example:

    http://localhost:8080/site/news/2019/11/the-medusa-news.html
    
  4. Return to the tab with the REST service. Refresh the response. Locate your browser's visitor ID in the JSON output (for example, 42fad129-1faa-48df-8310-a66502e9f8b7):

    { "success": true, "message": null, "data": { "items": [ { "id": "42fad129-1faa-48df-8310-a66502e9f8b7", "country": "", "segment": null, "lastActionTime": "2019-11-25T17:02:21.998-0800", "latitude": 0.0, "longitude": 0.0 } ], "count": 1 }, "errorCode": null }
  5. To see the document types collected for this visitor, request:

    http://localhost:8080/cms/_targeting/visitors/42fad129-1faa-48df-8310-a66502e9f8b7/details
    
    { "success": true, "message": null, "data": { "id": "42fad129-1faa-48df-8310-a66502e9f8b7", "targetingData": { "geo": { "collectorId": "geo", "city": "", "country": "", "continent": "", "latitude": 0.0, "longitude": 0.0 }, "documenttypes": { "collectorId": "documenttypes", "termFreq": { "myproject:newsdocument": 1 }, "size": 100 } }, "personaScores": [ { "id": "General Population", "name": "General Population", "segment": "General Population", "score": 1.0, "avatar": "", "segmentDescription": "General Population" } ], "lastActionTime": "2019-11-25T17:02:21.998-0800" }, "errorCode": null }

If you visited a news article backed by a myproject:newsdocument, the REST output should now show that this document type was viewed once.

Tip: Use a browser extension such as 'JSONView' (available for Chrome and Firefox) to format JSON output for easier reading.

In the CMS

After configuration, the Characteristics tab in the Content audiences application in the CMS will display a new entry for 'documenttype'. Refresh the CMS UI in your browser to see the update. To improve the display name and provide a user-friendly editor for target groups, continue to the next step.

Next

Add a Document Type Characteristic UI Plugin

Share Feedback
Page: /content/experiments-targeting/2-add-a-document-types-collector
Section: Content
Category *