How to run Analytics Experiments (A/B Testing) on WordPress

In our daily marketing scramble, we many times forget the importance of conversions and conversion rate and only focus on gaining new customerss. Due to this fact, we have setup in our own company a policy of always running tests on our clients’ websites.


We have included below a simple step by step guide on how to setup A/B testing using WordPress and Google Analytics Experiments.

Step 1 – Business Goals

a. Think about what are your core conversions are (purchase of product, form filled out, newsletter joined, commented on blog, etc)

b. Define a goal in Analytics
If you have not defined a goal in analytics, see our analytics goals article

Step 2 – Define Experiment

Create variation page in wordpress by visiting the “Pages” -> Add New. Create your new variation page with the specific element you want to test and publish. Try not to test out too many changes on your pages.


* don’t forget to note the live url for later.


Step 3 – Setup Experiment in Analytics

Visit the Behavior -> Experiments page:


a. Enter original page you want to test against (and click on start experiment)


b. Setup settings for Experiment

– name
– objective
– % of traffic to experiment on
– email notifications


c. Enter URL of Variation Page

* you can add more than one variation if desired
* check previews to make sure you are defining the correct pages


d. Add code to site pages


You will need to add the correct analytics code to begin your experiment. Follow the instructions below to proceed:

1. all pages must have analytics tracking code
2. the original page has to include additional code

Use the following format:

<?php if (is_page('') ):?>

<?php endif; ?>

Find the original page. edit the page in wordpress and look at url
“post=x” -> take the number and add to our code:

<?php if (is_page('x') ):?>

<?php endif; ?>

b. go to appearance -> editor -> header.php and paste the code with analytics
extra code right after the <head> tag and click on “update file”.

wordpress appearance editor

<?php if (is_page('') ):?>
<?php endif; ?>

Step 4 – Complete and set experiment live

Verify that you have two check marks underneath “Experiment Code Validation” and click on “start experiment”


That’s it! Let us know if you have any questions with A/B testing. We’ll be happy to answer your questions.

How to Spot Fraudulent Orders on Ecommerce Site

We have included the 6 most important tips on how to reduce credit card fraud on your ecommerce website. These tips are from a standpoint of AFTER A PURCHASE and how to spot a fraudulent order.


Tip #1 – Check IP Address

In all popular shopping carts, you will obtain an ip address for each order. You will want to check this ip address and IF the order ip is different from the billing and/or shipping address you will want to raise a flag and check further.

* Tip – Go to: – search for the ip of order and get location by city & state and compare.

Tip #2 – Different Billing & Shipping Addresses

Although this is a fairly common order, having the billing and shipping addresses being different, you will still want to look into these orders. For example, we do not recall any fraudulent orders from orders that had the same billing and shipping addreses. Note that if a billing and shipping address are in a different state completely than you may want to look at this order more in detail.

Tip #3 – Specific Countries

You will note over time that orders to specific countries have more probability of fraud orders. For example, in our latest project, Venezuela was almost always a fraud order. You may even want to consider banning country ip’s from your site.

Also, you may find specific cities, having more potential for fraud (in our real live example, it was Miami, Florida)

Tip #4 – Search on Google

For flagged orders, you may want to search google or google maps to better understand:

a. if order is to a residential or commercial area
b. if order is to a shipping company

You will also want to search for flagged orders for the address + the term “scam” or “fraud”. In one of our cases where an order was shipped to miami, florida to a shipping company, we found other ecommerce websites having the same fraud orders.

Tip #5 – Call Customers

You may want to have your phone number field in your cart as a mandatory field. If so, call your customer and say thanks for their order. During your call, also pay attention to any flags that may arise. (or if you don’t a hold of customer, please note this.)

Tip #6 – Multiple Orders & Quantity

If you receive multiple separate orders or orders with multiple quantity which is much different from your regular average orders, raise a flag and look into this order carefully.

See our video below:

Contact Form 7 WP – How to Add Event Tracking on New Universal Google Analytics

After searching for about 20 minutes, i could not find any hooks to explain how to track events in analytics for a wordpress site we are using (contact form 7). All you have to do is: 1. Make sure you have the latest google universal analytics code google-analytics-new-code 2. Go to Contact Tab in wordpress Admin contact-tab-form-7 3. Edit your form and scroll to bottom to “Additional Settings” additional-settings Enter the following: on_sent_ok: "ga('send', 'event', 'Contact Form', 'sent');"