code wiki / _hdl_build / nx_brand_conversion.nx
nx_brand_conversion.nx source
↩ module page · 31 lines · 1551 B
1// nx_brand_conversion.nx -- measure the CONVERSION PATH of a built page: a focused primary CTA (the conversion
2// entry), a clear journey/funnel (steps), and repetition that is present-but-not-spammy. bc_conv_score 0..3.
3// This is the measurable core of conversion/journey optimization; full A/B-funnel experimentation is nx_cms_abtest.
4// Library, standalone. 100% sovereign. license_tier: ORIGINAL
5import "nx_syscalls.nx"
6
7func bc_strlen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
8func bc_match_at(s: *u8, i: i64, n: i64, pat: *u8, plen: i64) -> i64 {
9 if i + plen > n { return 0 }
10 var j: i64 = 0
11 while j < plen { if s[i+j] != pat[j] { return 0 } j = j + 1 }
12 return 1
13}
14func bc_count(s: *u8, n: i64, pat: *u8) -> i64 {
15 let plen: i64 = bc_strlen(pat)
16 if plen == 0 { return 0 }
17 var c: i64 = 0
18 var i: i64 = 0
19 while i + plen <= n { if bc_match_at(s, i, n, pat, plen) == 1 { c = c + 1; i = i + plen } else { i = i + 1 } }
20 return c
21}
22func bc_cta_count(html: *u8, n: i64) -> i64 { return bc_count(html, n, "class=\"cta\"" as *u8) }
23// 0..3 conversion-path score.
24func bc_conv_score(html: *u8, n: i64) -> i64 {
25 let ncta: i64 = bc_cta_count(html, n)
26 var s: i64 = 0
27 if ncta >= 1 { s = s + 1 } // a conversion entry exists
28 if bc_count(html, n, "class=\"steps\"" as *u8) >= 1 { s = s + 1 } // a clear journey/funnel
29 if ncta >= 2 { if ncta <= 6 { s = s + 1 } } // focused repetition (not zero, not spam)
30 return s
31}