Simulation
Goal-seeking test
Adaptive allocation for two segments. The traffic is simulated and the planted rates are printed on the chart.
Understanding the labHow to use it and why you'd want to
Why you'd want to
Two charts use planted conversion rates for new and returning visitors, always from the same seed. After Accept the page queues lab_interaction for the view.
How to use it
- Each segment has two planted rates.
- The draw explores, then exploits.
- Every eighth arrival is recorded on the chart.
- After Accept, only the view is queued.
Simulation. Simulated traffic. The conversion rates are planted in the fixture and written on the chart. They are not measurements of this site. No model call.
Allocation
Share sent to headline A
New visitors
Planted rates, not this site: A 0.2, B 0.55.
- 8A 100%
- 16A 50%
- 24A 38%
- 32A 31%
- 40A 28%
Returning visitors
Planted rates, not this site: A 0.5, B 0.15.
- 8A 88%
- 16A 81%
- 24A 88%
- 32A 88%
- 40A 90%
Why am I seeing this? Each segment has its own planted rates. Epsilon 0.2 explores. Otherwise the arm with the higher simulated win rate so far gets the next arrival. The same seed always draws the same chart.
WalkthroughHow we built itShowHide
Example vendor setup is marked below. eVar and event numbers are examples. This lab does not call Adobe.
The goal-seeking test draws two charts from planted conversion rates for new and returning visitors, always from the same seed, and queues lab_interaction for the view after Accept. The lab does not call Adobe.
Plant two rates per segment
PLANTED sets arm A and arm B for new and for returning. The chart copy says the rates are not measurements of this site.
Explore, then exploit
simulateSegment seeds a generator from the segment name. Each round explores with probability 0.2. Otherwise it picks the arm with the higher win rate so far. A first pull has rate 0.
Record every eighth arrival
A win is a random draw under the planted rate. Every eighth arrival pushes the arrival count and A’s share of pulls. The default is 40 rounds, so the chart has five points.
Queue the view only
useLabView queues lab_interaction with action view and label page. The chart does not call trackLab. Shares and planted rates are not parameters.
From the code
Epsilon 0.2 explores. Otherwise the higher simulated rate gets the next arrival.
export function simulateSegment(segment: SegmentId, rounds = 40, seed = segment): AllocationPoint[] {
const random = mulberry32(hashSeed(`goal-test:${seed}`))
const counts = { a: { pulls: 0, wins: 0 }, b: { pulls: 0, wins: 0 } }
const points: AllocationPoint[] = []
let aPicks = 0
for (let i = 1; i <= rounds; i += 1) {
const rate = (arm: ArmId) => (counts[arm].pulls === 0 ? 0 : counts[arm].wins / counts[arm].pulls)
const explore = random() < 0.2
const arm: ArmId = explore ? (random() < 0.5 ? "a" : "b") : rate("a") >= rate("b") ? "a" : "b"
if (arm === "a") aPicks += 1
counts[arm].pulls += 1
if (random() < PLANTED[segment][arm]) counts[arm].wins += 1
if (i % 8 === 0) points.push({ arrivals: i, aShare: aPicks / i })
}
return points
}The chart calls the simulator. The caption says the rates are planted.
function Chart({ segment, locale }: { segment: SegmentId; locale: ReturnType<typeof useLocale> }) {
const points = simulateSegment(segment)
return (
<div className="min-w-0">
<p className="text-sm font-medium">{segment === "new" ? tr(locale, "New visitors", "Visitantes nuevos") : tr(locale, "Returning visitors", "Visitantes recurrentes")}</p>
<p className="mt-1 text-xs leading-relaxed text-muted-foreground">
{tr(locale, `Planted rates, not this site: A ${PLANTED[segment].a}, B ${PLANTED[segment].b}.`, `Tasas plantadas, no de este sitio: A ${PLANTED[segment].a}, B ${PLANTED[segment].b}.`)}Google and Adobe
Google queues lab_interaction after Accept. Adobe is an example of the same fields.
Queued only after Accept. The push is lab_interaction with lab_id goal-seeking-test, action view, and label page. Planted rates and A’s share are not parameters. This page does not queue run_demo. This site does not call Adobe.
Simplified shape of the object queued after Accept. Register any new parameter as an event-scoped custom dimension. This site does not call gtag('set').
dataLayer.push({
event: "lab_interaction",
lab_id: "goal-seeking-test",
action: "view",
label: "page",
})Example implementation. This site does not call Adobe. eVar77, prop77, and event77 are example variable numbers. In Launch, a data element reads the value and a rule sends it when the value changes. In the report suite, enable eVar77 with Most Recent allocation and expire it on the hit. A processing rule is unnecessary if the data element maps straight to that eVar.
Example alloy payload. _example is a placeholder schema, not a real tenant.
alloy("sendEvent", {
xdm: {
eventType: "web.webinteraction.linkClicks",
_example: {
goalSegment: "new",
},
},
})Example hit. eVar77 is hit-scoped in this example. prop77 dies at the same hit.
s.eVar77 = "new"
s.prop77 = "new"
s.events = "event77"
s.linkTrackVars = "eVar77,prop77,events"
s.linkTrackEvents = "event77"
s.tl(true, "o", "lab_interaction")Translation
Each lab field, the GA4 name, and the example Adobe variable. Scope is the part that usually gets lost in the translation.
Lab id
GA4. Parameter lab_id on lab_interaction. The value is goal-seeking-test.
Adobe. Example eVar77, expire on the hit.
Scope. Event on the hit. It names the page, not a user, and it does not cover the visit.
Action
GA4. Parameter action. This lab queues view.
Adobe. Example prop77, which dies at the hit.
Scope. Event. view is not a user property and it does not last for the visit. It is an event on the hit, not a user property, and it does not last for the visit.
Segment
GA4. Not sent. new and returning are arguments to the simulator.
Adobe. Example eVar77 if you copied the segment. Not sent.
Scope. A chart label on the hit. It is not a user property and it is not a visit field. It is an event on the hit, not a user property, and it does not last for the visit.
A share
GA4. Not sent.
Adobe. Example prop77. Not sent.
Scope. A simulated point. It is not an event metric, not a user property, and not a hit or visit metric.
Recommended next
Why these picksReading path transitions…