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.
- Open the Console.
- Navigate to
/targeting:targeting/targeting:collectors. - Add a node named
documenttypesof typetargeting:collector. - Set the property
targeting:classNameon the new node tocom.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.
- In the Console, go to
/targeting:targeting/targeting:characteristics. - Add a node named
documenttypeof typetargeting:characteristic. - Set the property
targeting:collectortodocumenttypes. - Set the property
targeting:scorerClassNametocom.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:
-
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.
-
In a new browser tab, open:
http://localhost:8080/cms/_targeting/visitorsThe initial JSON response will be empty if there have been no visitors (
count: 0):{ "success": true, "message": null, "data": { "items": [], "count": 0 }, "errorCode": null } -
In another browser tab, visit the home page of your site:
http://localhost:8080/siteThen navigate to a news article, for example:
http://localhost:8080/site/news/2019/11/the-medusa-news.html -
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 } -
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.