Using the visitor profile

When a request comes in to the HST, before passing control over to the main HST processing valves, the Relevance Module is invoked to first update the visitor data and then to create a profile using the updated data. This profile is used internally by the Relevance Module to show relevant content to the visitor but it is also available to the application for custom processing.

You can get a hold of the visitor profile using the static method

TargetingProfile profile = TargetingStateProvider.get().getProfile();

From the profile you can obtain both the raw visitor data as collected by the different collectors as well as the matching segments and their scores.

Accessing Specific TargetingData

If in an HstComponent implementation you want to access the targeting data of a certain collector, say the GeoIP collector, you can access as follows:

TargetingProfile profile = TargetingStateProvider.get().getProfile();
Map<String, TargetingData> targetingData = profile.getTargetingData();
GeoIPTargetingData geoIpTargetingData = (GeoIPTargetingData)targetingData.get("geo");

Other collectors data can be accessed in a similar way. If you want to access data from a custom collector, make sure that the custom collector has an interface in the shared lib. In your HST site webapp, you can only cast to the interface (also see Develop a Custom Collector).

 

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?