Skip to content

Developer notes

dispatch_before_display puts the popups that may show on the current page into #kv_pb_data (JSON): layout, triggers, targeting, texts, wheel slices with their chance. No coupon code is part of it. Checkout, sign-in and order pages get nothing.

The browser keeps per popup the version, the A/B variant, when it was seen and whether the visitor converted (localStorage key kv_pb, session key kv_pb_s). It asks kv_popup_builder.context for the cart subtotal and sign-in state only when a popup needs them.

Endpoints, all POST with Cache-Control: no-store:

Dispatch Purpose
kv_popup_builder.context Cart subtotal, signed in
kv_popup_builder.view Counts a view of a variant
kv_popup_builder.convert Sign-up, spin or click: checks the rules again, stores the address, picks the slice (random_int), hands out the code, counts the conversion
Table Contents
?:kv_pb_popups Settings of each popup
?:kv_pb_texts Texts per popup, variant and language
?:kv_pb_segments Wheel slices
?:kv_pb_stats Views and conversions per popup, variant and day
?:kv_pb_leads Addresses with prize and code; one per popup and address

window.kvPopups.show(id) opens a popup of the page, window.kvPopups.close() closes it.

Popups::isOn() decides whether pages get popups and whether the endpoints answer.