Today we're going to learn:
How to do A/B test with Google Analytics.
In Part 1 we went over adding all of the code that was required to Shopify to create two different templates. So let's just quickly go and review what we've got set up.
If we go to the first product and append ?view=OptionA to the end of the URL we can see the price is added to the buy button.
If we add ?view=OptionB , we now have a regular button without the price. Now that the options are set up, we can add it into Google Analytics to split the traffic that comes to our website 50/50 between the two options and begin to measure which is more effective.
In Google Analytics, we’ll set up a couple of things so that we can track the events. First, we’ll go to admin in the bottom left corner and we're going to select Goals under the View column on the right side.
In the Product-OptionA.liquid, you’ll need to search from the AddToCart button code.
Then you’ll need to include “ onClick=”_gaq.push([‘_trackEvent’, ‘Click’, ‘Add to Cart’, ‘Yes’});’
Back in Google Analytics, let's go and create a new goal. Go to goals, + NEW GOAL, it’ll be the add to cart template.
Click continue. The goal description is going to be “Add to cart”, and it's going to be goal ID number two ( I've already got one set up). Afterward, I'll click continue and begin to fill out the category values.
Reviewing our Shopify code, the first value we have is Click, so the first category in Google Analytics is also Click. The action is Add to Cart because that's what we called the second variable in our Shopify code. We’ll leave the Value blank, and set “Use the Event value as the Goal Value for the conversion” to YES.
Then we’ll click Save, and our goal is now set up.
Note: There is no way to delete a goal. You can only turn goals on or off.
Now we need to set up our experiment. Go to the home page and select behaviors, and then experiments, and click ‘Create experiment’.
Our experiment is to test displaying the price versus in the button vs no price in the button.
Name for this experiment
Price Vs No Price CTA
Objective for this experiment
Goal Set 1 > Add to cart
Percentage of traffic to experiment
Email notification for important changes
Now we need to configure the experiment. Open the first product to test and add ?view=OptionA to end of the URL. Copy the URL and paste it in Google Analytics Original Page > Webpage to experiment. Next add ?view=OptionB to the end of the URL. Copy the entire URL and paste it into Variant 1 > Web page to experiment.
Note: This experiment will not work if your store is password protected.
Click Next. Now the experiment is configured and we have to manually insert the code. Click “Manually insert the code” and copy the script code to your clipboard.
In Shopify, goto Themes > Online Store > Actions > Edit Code > Layout > theme.liquid and paste the code just beneath the <head> tag. Click Save.
Google Analytics will check to see that everything is configured correctly. Under “Review and start you will see two checkmarks beside Original and Variant 1 if everything is configured correctly. Now click Start experiment
And that basically wraps up everything you need to do to set up an A/B test inside Google.