Skip to content

Tgt- Building a reusable store gap analysis

This use case illustrates a concrete use of the Biron plugin in Zapier. If you are not yet familiar with how it works (authentication, query structure, variable management), please read the Biron × Zapier guide first before continuing.


A reusable sub-Zap, called by other Zaps, that produces a gap analysis for a store over a given period.

Starting from a store ID, a period, and a Slack thread, it retrieves performance data, submits it to an LLM, and posts the analysis as a reply to the original message.

The breakdown follows a KPI tree:

Revenue excl. VAT = Number of orders × Average basket
└── Number of orders = Conversion rate × N Visits

Sub-Zap trigger → Store query → Formatting → LLM → Slack → Sub-Zap end

A sub-Zap can only be triggered by another Zap that passes it the required variables. Configure the Start a Sub-Zap trigger by declaring the following four input variables:

VariableDescription
start_dateStart date of the period to analyze
end_dateEnd date of the period
shop_idStore identifier
slack_tsTS of the Slack message to reply to

Create a chart in Biron for the store and period passed in, using the start_date, end_date, and shop_id variables from the trigger.

Copy the NexusQL and paste it into the Biron Query block. The metrics to retrieve cover revenue and its breakdown, each with its realized value and target:

MetricRealizedTargetGap
Revenue excl. VAT✓✓% target achieved
Number of orders✓✓% target achieved
Average basket✓✓Delta
Conversion rate✓✓Delta
N Visits✓✓% target achieved

The flat Biron data must be restructured into nested JSON before being submitted to the LLM. Add a Code by Zapier block (Python) and use this prompt to generate the code:

Role: Python expert for Zapier.
Goal: Restructure flat data into nested JSON.
Available inputs (via input_data):
Keys in the format "Type - Metric" (e.g. Realized - Revenue excl. VAT, Target - Revenue excl. VAT)
and their associated values.
Request:
1. Only process keys containing " - ".
2. For each valid key, split into two parts: the Metric and the Type.
3. Group into a nested dictionary structured as follows:
{
"Revenue excl. VAT": { "Realized": "...", "Target": "..." },
"Number of orders": { "Realized": "...", "Target": "..." }
}
4. Convert to readable JSON (indented, special characters preserved).
5. Return the result in output with the key json_neste.

Add the Gemini block and fill in two inputs:

System instructions — the analyst framework, to copy as-is:

You are an Expert Retail Analyst specializing in commercial performance
and variance analysis.
Your goal is to read performance data in JSON format and clearly and concisely explain
why a store has exceeded or missed its revenue target (excl. VAT).
MANDATORY ANALYSIS RULES:
1. Analysis direction:
- If the % target achieved for revenue excl. VAT is > 100%: focus exclusively
on the positive levers.
- If the % target achieved for revenue excl. VAT is < 100%: focus exclusively
on friction points and negative levers.
- If the period is a full month: provide a review highlighting what worked or did not.
- If the period is partial: give trends to date and suggestions to
course-correct or consolidate the lead.
2. Noise management: Do not detail metrics whose result is between
95% and 105% of target. Simply mention that the contract is fulfilled.
3. KPI tree breakdown:
- Level 1: Analyze Revenue excl. VAT = Average Basket × Number of Orders.
Identify the main driver of the gap.
- Level 2: If Number of Orders shows a significant gap,
break down: Number of Orders = Conversion Rate × N Visits.
4. Target consistency: If Average Basket, Conversion Rate, and N Visits
are all on track, but Revenue excl. VAT is far from its target,
conclude that the revenue target is mathematically inconsistent.
Your tone must be professional, direct, and action-oriented.
Format: Slack-compatible, fewer than 10 lines.
Title: "Performance Analysis [Store] [Period]"
Slack formatting: bold is triggered with * (not **).

User prompt — to build by linking Zapier variables:

Here are the results for store [shop_id] for the period
from [start_date] to [end_date], in JSON format:
[json_neste]
Based on this data, write a gap analysis strictly following
your system instruction and the following structure:
1. Overall revenue summary to date
State whether the target is achieved or missed, and by how much in value.
2. Performance breakdown (Average Basket vs Orders)
Apply the rule: Revenue = Average Basket × Orders.
Highlight the factor(s) responsible for the gap.
3. In-depth acquisition analysis (if needed)
If order volume shows a gap, apply:
Orders = Conversion Rate × N Visits. Otherwise, skip this section.
4. Summary
Recap of the causes of the increase or decrease.
Mention the relevance of the initial target if the underlying
math is inconsistent.

Add a Slack block and configure:

  • Channel: the channel where the reply should be sent
  • Thread: the slack_ts variable passed at sub-Zap startup
  • Message Text: the response produced by the Gemini block

Add the Return Output block to signal to the calling Zap that the sub-Zap executed successfully and to pass back any return data if needed.


The calling Zap passes a store, a period, and a Slack thread. The sub-Zap retrieves the data, analyzes it, and replies directly in thread with a structured gap explanation — in under 10 lines, action-oriented.