How can I have a test show on the first page in a session regardless of URL
1 month ago
I want to test a certain experience for all landing pages, regardless of URL, so long as it is the first page in a users session. For example, I want have the internal search box exposed on mobile devices but only for the first page the visitor hits in that session. If I direct entry ford.com it will expose internal search on the homepage but subsequent pages. If I google "Ford F-150" and get taken to the landing page for the F-150 truck the internal search is exposed on that page but no subsequent pages.
Re: How can I have a test show on the first page in a session regardless of URL
One approach that I could think is to use a cookie to help you identify when a new session starts.
Depending on your site, you can do this when the page loads (if your page is static) or as the visitor interacts (if your site has app features).
document.cookie = 'lastVisit='+(new Date().getTime());
var lastVisit = document.cookie.replace(/(??:^|.*;\s*)test2\s*\=\s*([^;]*).*$)|^.*$/, "$1");
var currentTime = (new Date().getTime());
var difference = currentTime - lastVisit
return difference > 90 * 60 * 1000; // 90 minutes in milliseconds
You will need some developer help with the above, I haven't tested the code and it may have bugs.
Once you have setup all the above, you can change the targeting of your experiment accordingly:
URL regexp .*
"First Session Visit" equals true
Hope that this helped.