I am using pop-unders for a while now to monetize websites. From my experience I already knew that, when setup correctly and in the right environment, most visitors don’t mind them so much to leave your site right away. Anyway, I was recently asked to prove my experience with numbers and so I created a small test that should tell me how users really react on pop-unders. In this article I am going to explain this setup.

If you are interested in some real test results, have a look at my article on Pop-Under and Pop-Up ads.

1. Put visitors into groups

As a first step I needed to divide visitors into groups. The one group of visitors saw the pop-under, the other didn’t. The group key was created randomly (0 or 1) if there was none before, and than stored in a local storage variable. This is the code I used as high in the source code as possible – over the Analytics and the pop-under code.

var loadpopunder = localStorage.getItem('loadpopunder');
if(loadpopunder == null){
  loadpopunder = Math.floor(Math.random() * 2);
  localStorage.setItem('loadpopunder', loadpopunder);
</script>Code language: HTML, XML (xml)

2. Google Analytics Custom Variable

My test made use of the Google Analytics account my client already used. In a nutshell, I was sending a custom variable with the group-key we created above. There are a lot of great articles out there to learn more about custom variables in Analytics, so I am not going too deep into it.

In case the group-key was 1, I did send a value `Loading`, else the value was `NotLoading`.

if(loadpopunder == 1){
} else {
[/html]Code language: HTML, XML (xml)

You need to put this code inbetween the other analytics variables, but before the data is send. I was using the Google Analytics for WordPress plugin by Yoast. You can setup custom code under Analytics > Settings > Advanced > Custom Code in your WordPress dashboard.

3. Loading the Pop-Under code

The last step is to load the pop-under code based on the group the visitor is in. Please note that the ad tag below is artifical and you should adjust it to your ad code.

if(localStorage.getItem('loadpopunder') == 1) {
  document.write('<script type="text/javascript" src="http://ad.adserver.com/adscriptjs"><' + '/script>;');
</script>Code language: HTML, XML (xml)

The most important part in this code is to check your local variable for the group (line 7). In step 2 we decided to send the value `Loading` as a custom variable for the group key 1. So now we need to load the ad only, if the group key is 1 too.

The order of the three code blocks needs to be exactly the same in your code as it is above.

4. Evaluate the results

The last step is simply to evaluate the results.We always run tests for at least 7 days.

Visit your Analytics Dashboard and go to Audience > Custom > Custom Variables. My example from above uses the 5th variable slot, so I open the tab for Custom Variable (Key 5). There you should be able to see the variable name (e.g. PopUnder) and with a click on it the different variable values.

You can use almost all sections of Analytics (e.g. bounce rates, sources, devices) and compare them in regard of your custom variables.

Need help?

You want to do this test or a similar one and don’t have the technical experience to set it up? So why not hiring me?

The Author