In Sitecore Experience Platform releases before 8.1.0, content profiling data is saved on a visit-by-visit basis. The profile key values accumulated during the current interaction will not be used for future interactions made by the same contact.
As a result, profile-based personalization only considers the profile scores accumulated during the current visit or interaction, and ignores scores collected during previous visits or interactions that were made by the same visitor.
Note: In Sitecore 8.1, the Key behavior cache and Contact Behavior Profile functionalities were added to extend the ability to personalize based on a contact's historical behavior.
To enable personalization based on past website visits or interactions, you can create a custom personalization condition that loads the content profiling information from past visits or interactions that were made by the specific contact.
The default Sitecore.Analytics.Rules.Conditions.ProfileCondition class used in the /sitecore/system/Settings/Rules/Definitions/Elements/Visit/Profile Value condition can be used as an example for when you develop a custom condition.
To load the information about previous visits of the current visitor, it is possible to use the Tracker.Visitor.LoadAll method:
...
Sitecore.Analytics.Tracker.Visitor.LoadAll(VisitLoadOptions.Profiles, VisitorOptions.None);
...
The ProfileCondition class can be used as an example for your solution.
To load the information about previous interactions of the current contact, it is possible to use the LoadHistorycalData extension method and provide it with two arguments: current contact and the number of interactions in contact history that should be loaded.
...
var interactions = Sitecore.Analytics.Data.ContactRepositoryExtensions.LoadHistorycalData(Tracker.Current.Contact, 2));
...
The ProfileConditionXDB class method can be used as an example for your solution.
Note:
Before using this API, it is necessary to adjust the maximum number of interactions that can be loaded by the LoadHistorycalData method to more than 0. This can be done by using the following setting in Sitecore.Analytics.Tracking.config:
<setting name="Analytics.ContactHistory.MaxInteractions" value="0" />