code wiki / _hdl_build / nx_brand_conversion_gate.nx

nx_brand_conversion_gate.nx source

↩ module page · 34 lines · 1822 B

1// nx_brand_conversion_gate.nx -- the conversion-path score rewards a real branded page and flags a page with no 2// conversion path. 100% sovereign. expect_exit: 0 3import "nx_syscalls.nx" 4import "nx_sitegate_emit_lib.nx" 5import "nx_brand_conversion.nx" 6 7 8func ib(v: i64, lo: i64, hi: i64) -> i64 { if v < lo { return 0 } if v > hi { return 0 } return 1 } 9 10func main() -> i64 { 11 let tot: *i64 = sys_mmap(32) as *i64 12 tot[0]=0; tot[1]=0 13 let lp: *i64 = sys_mmap(16) as *i64 14 gw("=== nx_brand_conversion_gate -- conversion-path measurement ===\n" as *u8) 15 16 let page: *u8 = sys_read_file("web_assets/andelin_branded.html" as *u8, lp) 17 let pn: i64 = lp[0] 18 var sc: i64 = 0; var nc: i64 = 0 19 if (page as i64) != 0 { if pn > 0 { sc = bc_conv_score(page, pn); nc = bc_cta_count(page, pn) } } 20 gw(" andelin_branded.html: CTAs=" as *u8); gn(nc); gw(" conversion-path score=" as *u8); gn(sc); gw(" / 3\n" as *u8) 21 t_row("C1 real branded page has a strong conversion path (score >= 2)" as *u8, ib(sc, 2, 3), tot) 22 t_row("C2 the page has a focused primary CTA repeated (CTAs >= 2)" as *u8, ib(nc, 2, 99), tot) 23 24 let bare: *u8 = "<!doctype html><html><body><p>no call to action here</p></body></html>" as *u8 25 var bn: i64 = 0; while bare[bn] != (0 as u8) { bn = bn + 1 } 26 let scb: i64 = bc_conv_score(bare, bn) 27 gw(" bare page conversion-path score=" as *u8); gn(scb); gw(" / 3\n" as *u8) 28 t_row("C3 a page with no conversion path scores 0 (the metric discriminates)" as *u8, ib(scb, 0, 0), tot) 29 30 gw("\nrows pass=" as *u8); gn(tot[0]); gw(" fail=" as *u8); gn(tot[1]); gw("\n" as *u8) 31 if tot[1] == 0 { gw("VERDICT=GREEN -- conversion path measured (CTA + journey + focus). Full A/B funnels = nx_cms_abtest.\n" as *u8); return 0 } 32 gw("VERDICT=RED\n" as *u8) 33 return 1 34}