UTM Link Parameter AB Testing Condition for Oxygen

YouTube video

Written By

Jonathan Jernigan

Often when you’re working on marketing campaigns, it is important to use link tracking to determine what ads and what sources are resulting in the most conversions. To take this a step further in Oxygen, we can do A/B testing by showing and hiding elements of vary kinds based on typical URL parameters such as UTM Campaign, Medium, Source, Term, and Content.

At the end of this post, you’ll find the code snippet you can add to your website to use this condition as described in the rest of the article.

Google provides a fantastic URL builder tool that this condition is based on: https://ga-dev-tools.appspot.com/campaign-url-builder/

You’ll notice that the tool is setup with 5 main parameters that you can fill in to fit your specific use case:

  • Source
  • Medium
  • Name
  • Term
  • Content

The tool requires you to use your website URL (destination URL) source, medium, and a name, with term and content as optional fields.

You can input whatever you need to into

Let’s say you are running paid ads on Google for your clothing website and you want to track an ad promoting your spring sale for women’s shoes and you’re testing version 1 of the ad.
An example URL would look like this:

Based on the example above you’ll notice after your destination URL, you have a ? followed by all the parameters you set in the tool.

Let’s say for example that you want to show a blue button instead of an orange button on that landing page, only to those visitors that come from that specific ad, with those parameters in the URL. You simply use that full URL from the campaign builder tool as the ad’s destination in your ads campaign and then move to Oxygen Builder.

In Oxygen, you simply choose the element you want to show, add the conditions using the built in conditions modal, choose the condition operator (and / or), add the data into each condition and now you will only see those elements on the front-end if those URL parameters are present in the users address bar on page load.

For instance, if your campaign source is Google, your first condition would be UTM Source = google.
Next, click Add Condition and if your medium is something like CPC, your next condition would be UTM Medium = cpc.

Note: This is case sensitive, so use all lowercase and no spaces to be consistent.

So, if the user visits your website by coming directly to your page, they will see your default button and the original image. But if they visit from your Google ad, they will now see the blue button and the new image.

Pretty neat, right? Hopefully this helps you take your marketing efforts to the next level!

To use this code, add the plugin Code Snippets to your website or use WPCodeBox. Add a new code snippet, call it whatever you’d like and paste the code below in the content box. Leave “run snippet everywhere” checked, save, and go to Oxygen. Your UTM parameters will now be available for use as described above.

if( function_exists('oxygen_vsb_register_condition') ) {
    global $oxy_condition_operators;

    function oxy_access_code_callback_source($value, $operator) {
        return oxy_access_code_callback($value, $operator, 'utm_source');
    function oxy_access_code_callback_medium($value, $operator) {
        return oxy_access_code_callback($value, $operator, 'utm_medium');
    function oxy_access_code_callback_name($value, $operator) {
        return oxy_access_code_callback($value, $operator, 'utm_name');
    function oxy_access_code_callback_term($value, $operator) {
        return oxy_access_code_callback($value, $operator, 'utm_term');
    function oxy_access_code_callback_content($value, $operator) {
        return oxy_access_code_callback($value, $operator, 'utm_content');

    function oxy_access_code_callback($value, $operator, $param) { 
        if( $operator == '==') {
            if( !empty( $_GET[$param] ) && $_GET[$param] == $value ) {
                return true;
            } else {
                return false;
        else if( $operator == '!=' ) {
            if( empty( $_GET[$param] ) || $_GET[$param] != $value ) {
                return true;
            } else {
                return false;

    oxygen_vsb_register_condition('UTM Source', array('options'=>array(), 'custom'=>true), $oxy_condition_operators['string'], 'oxy_access_code_callback_source', 'AB Testing');
    oxygen_vsb_register_condition('UTM Medium', array('options'=>array(), 'custom'=>true), $oxy_condition_operators['string'], 'oxy_access_code_callback_medium', 'AB Testing');
    oxygen_vsb_register_condition('UTM Name', array('options'=>array(), 'custom'=>true), $oxy_condition_operators['string'], 'oxy_access_code_callback_name', 'AB Testing');
    oxygen_vsb_register_condition('UTM Term', array('options'=>array(), 'custom'=>true), $oxy_condition_operators['string'], 'oxy_access_code_callback_term', 'AB Testing');
    oxygen_vsb_register_condition('UTM Content', array('options'=>array(), 'custom'=>true), $oxy_condition_operators['string'], 'oxy_access_code_callback_content', 'AB Testing');

Signup for the most inconsistent newsletter this side of the Mississippi

Delivered on a regular-as-I-can basis, I'll share with you the tl;dr of new blog posts and videos, exciting announcements, and other valuable information from around the WordPress ecosphere. You'll never get more than one email per week from me.

"*" indicates required fields

This field is for validation purposes and should be left unchanged.