Rich-text Reply

Exclude visitors based on URL

intuitben 05-03-16

Exclude visitors based on URL

I’m trying to create an experiment where a segment of visitors are excluded if they have visited a particular URL on the site.

 

“If Visitor sees www.test.com/solutions then exclude them from this experiment”

 

We do not have the enterprise version so I don’t seem to be able to use the visitor behaviour method.  Plus I dont have the time for the dev team to add any additonal code to the page.

 

could anyone help?

 

 

 

JasonDahlin 05-03-16
 

Re: Exclude visitors based on URL

@intuitben - When you say you are not on the Enterprise Plan, I presume you are on the Free plan and not the Pay As You Go plan.  Pay As You Go provides for Custom Javascript which would allow you to exclude users who have visited the page using the same methodolgy as I have outlined below, but they would actually be excluded from the experiment rather than just unaffected.

 

If you are on the Free plan, the only choice I know of is to write code into your test variation so that the variation only affects users who do not meet a certain condition.  Everyone would still be in the experiment, but the experiment would only affect users who have not visited that URL.

 

To accomplish this... add code such as the following to the www.test.com/solutions page (you can do this by creating an experiment that targets only that page and have the experiment contain only one variation (the control) which runs the following code:

try {
    window.localStorage.optExclude = 'Y';
} catch(e) { }

Then in your experiment's test variation, use code that makes it not do anything if the condition you set on the exclusion URL exists:

var showVariation = true;
try {
    if (window.localStorage.optExclude == 'Y') {
        showVariation = false;
    }
} catch(e) { }

if (showVariation) {
    //Your variation's code goes here
}

The downside of these users being in your experiment is that they will be counted in Optimizely's results dashboard, muddying your ability to judge the results.  If you are using another platform to record your success metrics, such as Google Analytics or Site Catalyst, etc., then the impact of this can be lessened by pulling the KPIs only for those users who have not seen the exclusion URL.

 

 

--Jason Dahlin
Analytics and Testing Guru Smiley Happy
Experimentation Hero