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:

  1. Waits for Alloy to Load

    The script ensures the Adobe Web SDK (Alloy) is fully loaded before making any personalization requests.

  2. Gets the User’s Location

    It uses the browser’s Geolocation API to retrieve the user’s current latitude and longitude.

  3. 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

  4. 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.”

  5. 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
      }
    }
    
  6. Retrieves and Renders Offers

    Receives offers returned by AJO Decisioning.

    Decodes the HTML content.

    Dynamically injects the offers into the

    element.