These APIs return data about the server time, user audiences, and user location. Except for Get Accurate Time, the following APIs after Dynamic Yield fills the attributes from the back-end. Therefore, we recommend verifying that the attributes exist on the page before attempting to fetch their values. This can be done using the Wait for Dynamic Yield Script API.
Get Accurate Time
Returns the time based on Dynamic Yield’s clock adjusted to your time zone. This function is ideal when wanting to incorporate into any Dynamic Content or Template one specific time/clock that is unified and consistent for all visitors, such as in a promotion countdown notification.
Syntax
DYO.accurateNow()
Get Number of recently purchased items
Returns the number of items that were bought from the user's Dynamic Yield User ID.
Syntax
DY.rpCount
Get Number of recently viewed items
Returns the number of items that were previously viewed from the user's Dynamic Yield User ID.
Syntax
DY.rvCount
Get User Audiences
Returns the list of the Audiences that the current user is a member of. The data is returned as an array of numbers (e.g. [1023,1056,1125])
Syntax
DY.ServerUtil.getUserAudiences()
Get User Location
Returns location information about the site visitor. DY.geoFields returns the country, state, and city. DY.geoCity only returns the city.
Syntax
DY.geoCity
DY.geoFields
Examples with Results
> DY.geoCity
> "US_NJ_Clifton"
> DY.geoFields
> {city="Clifton", state:"New Jersey", country:"United States"}