What the JavaScript does
The JavaScript dynamically fetches weather information based on the user’s location and uses Adobe Experience Platform (AEP) to deliver personalized offers. Here’s a breakdown of the steps:
-
Waits for Alloy to Load
The script ensures the Adobe Web SDK (Alloy) is fully loaded before making any personalization requests.
-
Gets the User’s Location
It uses the browser’s Geolocation API to retrieve the user’s current latitude and longitude.
-
Fetches Weather Data
It calls the OpenWeatherMap API to get current weather details:
Temperature (in °F)
Weather Condition (for example, “Rain,” “Clear”)
City Name
Humidity
-
Display Weather Info on the Web Page
Updates the DOM with a message like:
“Current temperature in San Diego is 72°F with Clear skies.”
-
Sends Weather Context to AEP
Uses alloy(“sendEvent”) to send contextual weather data to AEP
xdm: { eventType: "decisioning.request", _techmarketingdemos: { temperature: temp, weatherConditions: condition, cityName: city } }
-
Retrieves and Renders Offers
Receives offers returned by AJO Decisioning.
Decodes the HTML content.
Dynamically injects the offers into the
element.