Lightweight A/B testing using Velocity
Hi @sanfordwhiteman I've been looking to use this
https://blog.teknkl.com/lightweight-a-b-testing-in-velocity/
but also with different (tracked) links. I'm aware of the multiple tracked links issue but I though renaming the variable would work e.g.
#set( $random = $math.random(0,3) )
#set( $member_cta = {
0 : {"text": "Text 0",
"link_text": "Link text 0",
"url": "www.example.com?l=0"
},
1 : {"text": "Text 1",
"link_text": "Link text 1",
"url": "www.example.com?l=1"
},
2 : {"text": "Text 2",
"link_text": "Link text 2",
"url": "www.example.com?l=2"
}
})
#set($url_new = $member_cta[$random].url)
${member_cta[$random].text}
<a href="https://${url_new}" style="color: #ffffff;">
${member_cta[$random].link_text}</a>
${url_new}
</div>
And indeed it was, but turns out it was only working 'randomly'. I only want to output 1 link, what am I doing wrong here?
Thanks
Jon