I'm using Sitecore.Analytics.Tracker
for personalizations on my site. I have added the ability for the user to manually change their zipcode, which changes what they see on certain parts of the site. The zipcode is retrieved with Tracker.CurrentVisit.PostalCode
public string GetCurrentZipCode()
{
return Tracker.CurrentVisit.PostalCode.IsNotNullOrEmpty() ? Tracker.CurrentVisit.PostalCode : String.Empty;
}
public void SetCurrentZipCode(string zip)
{
Tracker.CurrentVisit.PostalCode = zip;
}
This works but is finicky; every now and then when I reload the page, the zip code will have changed back to the default, which I discovered is because sometimes when the page loads PostalCode has changed back to an empty string.
Why is Tracker.CurrentVisit.PostalCode
getting reset? Is this a setting in Sitecore? How can I stop it? Ideally the value of PostalCode should persist for the entire session.