Test Only Convertible Traffic: How to Block Internal Traffic from Google Optimize for Your Site

Since people working at home regularly visit their organization’s website, we’ve created a solution to block internal traffic from your site so that your testing stays clean and accurate. Here’s a three step fix to make Google Optimize work better for your tests. This fix is especially helpful for B2B sites with low traffic.  

In this tentatively optimistic season, people are beginning to go back into the office, but they still are working from home more than they ever did before the pandemic. These days, we’re less worried about most working from home problems, because, well, we’ve figured it out—some of us in a trial by fire! However, we do have to worry about how to filter out all the internal traffic that we can no longer easily identify by VPN or IP address. 

Why does the ability to filter internal traffic from a test matter?

Easy. Because you want your sample to be of the total convertible  population on your site.

image6 1

If you’re an optimization expert at, say, Nike, you don’t care if there’s a little bit of internal traffic in your analytics and testing platform and you’re not able to exclude it because you don’t have the person’s home IP address. For Nike, a little internal traffic is a drop in the ocean, plus employees need shoes, too. But, for lower trafficked sites, especially B2B lead generation sites, every time an employee visits your site, they’re unintentionally diluting tests’ conversion rates by inflating what’s perceived as your total addressable market. 

A real-life example of a client who needed to block internal traffic from Google Optimize

This was happening with one of our B2B clients. Our client has fairly low traffic to their site, but for any visitor, a valuable sales opportunity is created. We ran a test on their form page that gets less than 1,000 visitors per week. 

Since Google Optimize is session-based,  it records every session to the targeted page(s) as an opportunity to convert and increases the denominator of the tests’ conversion rates incrementally. When curious internal client traffic wanted to see the new version of the page, they unintentionally inflated the denominator of the challenger more so than the control. Not only does this create noise in the data (error variance), but because internal traffic was more likely to go back to the challenger variation over and over coupled with Google Optimize being session-based, we were playing a rigged game—our challenger didn’t have a fair fight from the start.

This didn’t work for us. So, we created the following step-by-step solution to exclude internal traffic from our tests.

Step One: Add two tags into your tag management system or hard code them on your site.

Our example will be instructions for Google Tag Manager, but the custom code can be used in many ways.  

First, create a tag for setting cookies. Any Cookie. (Anyone getting hungry?)

(The setPersistentCookie function referenced in this code can be used over and over again for targeting, not just for the internalTraffic cookie.)

  • Create New Tag and call it “Cookie Setting Tag.”
  • Select Custom HTML under Tag Configuration.
  • Click Advanced Settings.
  • Under Tag Firing Priority, set to a high value (like 99). (This ensures this tag is available before you set the cookie with separate code.)
  • Add the code in the code block below.
  • Click on Triggering and select “All Pages.”

How to create a tag for setting cookies so that the Google website optimizer will block internal test traffic to website.

				
					<script>
function setPersistentCookie(name, value, expires) {
 var cookie = name + "=" + value + "; path=/; domain=." + location.hostname.replace(/^www\./i, "");
if (typeof expires !== "undefined") {
var now = new Date();
now.setTime(now.getTime() + expires * 24 * 60 * 60 * 1000);
cookie += "; expires=" + now.toUTCString();
}
 document.cookie = cookie;
} 
function setSessionCookie(name, value) {
var cookie = name + "=" + value + "; path=/; domain=." + location.hostname.replace(/^www\./i, ""); 
document.cookie = cookie;
} 
function getCookie(name) {
var cookies = document.cookie.split(";"),
toReturn;
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].trim();
if (cookie.indexOf(name + "=") === 0) {
toReturn = cookie.substring((name + "=").length, cookie.length);
}
} 
return toReturn;
}
</script>

				
			

The second tag is the internalTraffic cookie setting tag.

(This leverages the setPersistentCookie function to set the value of internalTraffic to either true or false, depending on the existence of the query string parameter or existing cookie value.)

How to create a tag for setting cookies (internalTraffic Cookie Set) so that the Google website optimizer will block internal test traffic to website.

  • Create New Tag and call it “internalTraffic Cookie”
  • Select Custom HTML under Tag Configuration
  • Add the code in the code block below.
  • Click on Triggering and select “All Pages.”
				
					<script>
if (window.location.href.indexOf('?internaltraffic=true') > -1) {
  setPersistentCookie("internalTraffic", "true", 365);
} else if (document.cookie.indexOf('internalTraffic=true') === -1 && window.location.href.indexOf('?internaltraffic=true') === -1) {
  setPersistentCookie("internalTraffic", "false", 365);
}
</script>

				
			

*You can optionally create a variable within the tag manager for ease of access later down the road: Instead of having to call the variable, you have it in GTM to just select. (Reach out if you want to know more about that).

Step Two: Tell your coworkers to click a link, and remind them this is about cookies, not phish.

Once the GTM tags go live, ask people internally to go to your website with the query parameter “?internaltraffic=true” appended to the end of the URL. So here at Search Discovery Inc, I would tell people to go to https://www.searchdiscovery.com/?internaltraffic=true. This will set a first party cookie in their browser for 365 days. 

Note: This will not get around the impact of Safari ITP on first party cookies (which will expire 7 days after being set, regardless of the expiration we have set in our setPersistentCookie function), nor will it hold for 365 days if your coworkers are regularly clearing their cookie cache. Because of this, it might be good practice to include the ?internaltraffic=true parameter click instructions as part of every test launch.

Step Three: When you set up a new test in Google Optimize, exclude your internalCookie from getting into your experiments.

Under Audience Targeting, select “First Party Cookie.”

When you set up a new test in Google Optimize, exclude your internalCookie from getting into your experiments.

Then set targeting to be internalTraffic equals false.

When you set up a new test in Google Optimize, exclude your internalCookie from getting into your experiments.

Optionally, if you have really curious stakeholders who want to see tests in flight, you can duplicate any of your tests and set the targeting to internalTraffic = true. That will show you how much internal traffic you would have had muddying up your results, and, as a side-benefit, it gives you an evergreen way to QA your live tests!

That’s it! You’ve learned how to exclude internal traffic from Google Optimize!

Now your data will be less muddied by noise and error variance, and tests won’t take as long to complete. If you want help targeting convertible traffic, or if you’re unclear about the impacts of cookie-expiration on your tests, please feel free to reach out below. 

Looking for more optimization resources? Try these: 

Search Discovery provides a full range of Optimization Services to help you use an evidence-driven approach to learn about your customers and deliver real value against your business goals.

Related Posts

Join the Conversation

Check out Kelly Wortham’s Optimization based YouTube channel: Test & Learn Community.

Search Discovery
Education Community

Join Search Discovery’s new education community and keep up with the latest tools, technologies, and trends in analytics.

Follow Us

Share

Share on facebook
Share on twitter
Share on linkedin
Scroll to Top