We are testing different home pages for our WordPress-based site. We want people who visit to land on them randomly so we can determine how many follow through to the sign-up process in each design.
We have adword campaigns that direct to the corresponding home pages (A, B, C or D) when clicked on but the domain name is just the one, of course. If someone types the URL they’ll be directed to the one domain (Home A).
Our landing pages are as follows:
Home A: www.mydomain.com
Home B: www.mydomain.com/?page_id=119
Home C: www.mydomain.com/?page_id=132
Home D: www.mydomain.com/?page_id=153
I’m trying to do this through .htaccess but can’t get it to work. Can you please suggest a way?
We could have some person landing on “Home C” and the next person on “Home D”, next person on “Home A” and so on in a cycle. It’s not really random but it works for us as it ensures “a random person would land on a random Home page”
PS: We leave a cookie to ensure that a returning visitor who signed up would get the same Home page. The method used should also take this into account.
Thanks to all!
Miguel
It’s not possible to randomize redirects via .htaccess. What you need to do is to redirect from within your wordpress index file.
Here’s some example of what I would include in index.php in the beginning:
Another approach will be, not to redirect at all and trick wordpress into thinking that user is trying to access with params page_id = N.
Additionally to a php solution, if you have access to the server’s config or the vhost config, you can create a randomized RewriteMap. So you’d have a file somewhere that looks like (let’s say it’s called home_pages.txt):
Then you declare the map in either apache’s server or vhost config:
Then either in vhost, server, or the htaccess file in your document root, you can add:
This rule needs to be before whatever rules you may have in your htaccess file already.
The first condition makes it so any internal redirect skips the rule entirely (prevents looping). Then the rule states that requests for
/
(the home page) invokes the rewrite map’s “home” hash (that’s why there’s a “home
” in front of each URI in the file) and randomly pulls one of them and internally redirects to that one.The URL in the browser’s location bar remains
http://example.com/
but they’ll get a random page from the “home_pages.txt” file.If you are using SQL for the site you can increment an integer for each access and module it by 4 [because of your 4 homepages in your network] and make load the homepage making calls depending on that integer.
In this case you can have 4 different calls of the homepage, even if a user access the network from a mobile device.
You might want to edit index.php with an array of URLs and a random integer from 0 to 3, that would returns randomly one of the URLs in the list.