Best practice for assigning A/B test variation based on IP address

Posted by mojones on Stack Overflow See other posts from Stack Overflow or by mojones
Published on 2010-03-26T12:30:07Z Indexed on 2010/03/26 12:33 UTC
Read the original article Hit count: 358

Filed under:
|
|
|

I am starting to write some code for A/B testing in a Grails web application. I want to ensure that requests from the same IP address always see the same variation. Rather than store a map of IP->variant, is it OK to simply turn the IP address into an integer by removing the dots, then use that as the seed for a random number generator? The following is taking place in a Grails Filter:

def ip = request.remoteAddr
def random = new Random(ip.replaceAll(/\./, '').toInteger())
def value = random.nextBoolean()
session.assignment = value
// value should always be the same for a given IP address

I know that identifying users by IP address is not reliable, and I will be using session variables/cookies as well, but this seems to be useful for the case where we have a new session, and no cookies set (or the user has cookies disabled).

© Stack Overflow or respective owner

Related posts about abtest

Related posts about grails