Using the Visitor Profile
When the HST receives a request, the Relevance Module runs before the main HST processing valves. The module updates the visitor data and creates a profile based on the latest information. The Relevance Module uses this profile to determine which content to display to the visitor. The profile is also accessible to your application for custom logic.
To access the visitor profile, use the following static method:
TargetingProfile profile = TargetingStateProvider.get().getProfile();
The profile provides access to both the raw visitor data collected by various collectors and to the matching segments with their scores.
Accessing Specific Targeting Data
To retrieve targeting data from a specific collector, such as the GeoIP collector, in an HstComponent implementation, use the following approach:
TargetingProfile profile = TargetingStateProvider.get().getProfile(); Map<String, TargetingData> targetingData = profile.getTargetingData(); GeoIPTargetingData geoIpTargetingData = (GeoIPTargetingData)targetingData.get("geo");
You can access data from other collectors in a similar way. To use data from a custom collector, ensure that the custom collector defines an interface in the shared library. In your HST site web application, cast only to the shared interface. For more details, see Develop a Custom Collector.