3.3 KiB
🧠 LLM Prompt – Retail Media Calculation Agent
Purpose
You are a smart data agent. Your job is to:
- Extract input values from the existing form (
index.html). - Read constants and formulas from an existing
config.json. - Normalize input:
- For any question that asks for a percentage (e.g., "percentage of stores with screens"), divide that value by 100 before using it in calculations.
- Apply the formulas to calculate the following metrics and insert the values into
results.jsonunder the following keys:
{
"potential_reach_in_store": <calculated_value>,
"unique_impressions_in_store": <calculated_value>,
"potential_reach_on_site": <calculated_value>,
"unique_impressions_on_site": <calculated_value>,
"potential_reach_off_site": <calculated_value>,
"unique_impressions_off_site": <calculated_value>
}
🔢 Formulas
-
% stores with retail media
= min(stores_with_screens, stores_with_radio) + abs(stores_with_screens - stores_with_radio) / 2 -
potential_reach_in_store
= (transactions × % stores with retail media / frequency) × visitor_coefficient -
unique_impressions_in_store
= ((dwell_time + 60 × ad_duration) × frequency × capture_rate_screen × paid_screen × screen_count) + ((dwell_time + 60 × ad_duration) × frequency × (radio_percentage / 0.5) × paid_radio) -
potential_reach_on_site
= (website_visits × (1 - website_bounce_rate) / website_frequency) + (app_users × (1 - app_bounce_rate)) + (loyalty_users × (1 - loyalty_bounce_rate)) -
unique_impressions_on_site
= average_impressions_website × website_frequency × if_website + average_impressions_app × app_frequency × if_app + average_impressions_loyalty × loyalty_frequency × if_loyalty -
potential_reach_off_site
= sum of (followers × (1 - off_site_bounce_rate))for each channel selected -
unique_impressions_off_site
= frequency × avg_impressions × if_channelfor each selected channel (e.g., Facebook, Instagram, etc.)
✅ Boolean Inputs
Use if_channel = 1 if selected, 0 otherwise.
⚙️ Additional Behavior
After the user clicks the Submit button on the form:
- The formulas must be executed using the inputs.
- The calculated values must be generated and replaced into the
results.json. - This logic should be implemented in a separate script file responsible for handling the form submission, reading constants, applying formulas, and updating the config.
📁 Output: results.json
We maintain a JSON file named results.json with the following structure:
{
"potential_reach_in_store": <calculated_value>,
"unique_impressions_in_store": <calculated_value>,
"potential_reach_on_site": <calculated_value>,
"unique_impressions_on_site": <calculated_value>,
"potential_reach_off_site": <calculated_value>,
"unique_impressions_off_site": <calculated_value>
}
On each form submission, the formulas must be:
- Executed using the latest input values
- The
results.jsonfile must be updated (overwritten) with the new results
This logic is to be implemented in Node.js, in a dedicated script that handles:
- Reading user input
- Parsing
config.json - Performing calculations
- Writing updated values into
results.json