Google Content Experiments replaces Google Website Optimizer as the tool which website owners can use for the split testing of their site’s pages.
Content Experiments is a tool which can be found in your Google Analytics account from which you can do your split testing with.
The WP Content Experiments & Event Tracking plugin gives you the ability to carry out Google split testing on your WordPress site by providing an easy interface which you can use to paste the relevant google experiments control code into the header of the page/post of your choice.
In addition, if you want to perform event tracking on buttons, links or other elements so you can analyse the data in your google analytics account, this plugin allows you to easily add the event tracking code to particular elements from your wordpress post/page editor window.
In order to run content experiments or event tracking, you will need a Google Analytics account and have your tracking code inserted into your blog.
To learn more about how to use Google Analytics, there is a great blog post from my friends at firstsiteguide.com who explain how to use Google Analytics for WordPress.
Therefore this plugin requires that you have the Google Analytics For WordPress plugin installed and configured.
Download the WP Content Experiments & Event Tracking Plugin:
Version: 1.0
Requires: 3.1
Tested up to: 3.4.1
Price: FREE
Installing the WP Content Experiments & Event Tracking Plugin
- FTP the wp-content-experiments
/wp-content/plugins/
directory, OR, alternatively, upload the wp-content-experiments.zip file from the
Plugins->Add New
page in the WordPress administration panel. - Activate the wp-content-experiments plugin through the ‘Plugins’ menu in the WordPress administration panel.
Using the WP Content Experiments & Event Tracking Plugin
Pre-requisites:
- You will need an active google analytics account. If you don’t have one, you can create a new one here:
http://www.google.com/analytics/ - You will need to have installed and configured the Google Analytics for WordPress plugin which can be found here:
http://wordpress.org/extend/plugins/google-analytics-for-wordpress/
(this will ensure that your Google Analytics tracking code will be inserted inside your site’s <head> tags)
Adding Content Experiments code to a post or page
Step 1: Using the WP editor open the page or post you wish to treat as the “Original” page for the content experiment you want to perform.
Please see the google help pages for how to setup/run experiments:
https://support.google.com/analytics/bin/answer.py?hl=en&answer=1745216
Step 2: Enable the checkbox in the “Content Experiments For WP” section to activate the feature. (see 1 circled in figure below)
Step 3: Paste the Google Content Experiments code into the text box. (You will get this code from your Google Analytics account)
(see 2 circled in figure below)
Important: You should only paste the content experiments code in the page which you nominate as the “Original” in the experiments setup of your Google Analytics account, ie, do not paste the code in the “Variation” page(s)
Step 4: Save your settings by saving or updating the post or page, ie, click “Update” button.
You can check whether your code was added correctly within the page’s <head></head> tags by viewing the source of the web page.
Adding google event tracking code to an element on a post or page
Pre-requisite: To perform event tracking you will need to set up a goal in your Google Analytics account.
Please see the google help pages: http://support.google.com/analytics/bin/answer.py?hl=en&answer=1032415
Step 1: Choose the page/post which you want to perform event tracking on. For example let’s say we had the following page which consists of a form with a button:
Step 2: Get the CSS class name or ID of the element which you want to do event tracking on. For our example it is the “Send” button shown in the figure above.
The easiest way to get class name or ID is to use Firebug by right-clicking on the element in your browser and selecting “Inspect element” (see figure below)
You can then obtain the CSS class name or ID name (depending on your situation) as shown below. You will need this name for the next step.
Step 3: Using the WP editor open the page or post you wish to perform event tracking on, ie, in our case it will be the page containing the form in the figures above.
Step 4: Enable the checkbox called “Enable Event Tracking for this page” in the “Event Tracking” section to activate the feature. (see circled item 1 in figure below)
Step 5: Enter the values for the Category, Action and Label fields. (These values should have been set by you when you were configuring your goal in your Google Analytics account) (see circled items 2, 3, 4 in figure below)
Step 6: Enter either a CSS ID name and/or CSS classname of the element you wish to track. (see circled items 5 in figure below)
Step 7: Save your settings by saving or updating the post or page, ie, click “Update” button.
Tip: You can check whether your event tracking code was added correctly to the appropriate element by viewing it in firebug, ie, by rightclicking the element and selecting “Inspect Element with Firebug” when using the Firefix browser. You should see the code which this plugin added as per the example below
(click image to see larger version):
Pedro Pereira says
May 20, 2014 at 10:03 pmHello,
I have installed the plugin. My objective is to trace everytime a person clicks in a button.
In this page (http://www.digitaldiscovery.com.pt/contacto/) I have a buttom in the end of the form that says “Enviar”wich means “Send”.
Now I have folow all the instructions here to trace everytime someone clicks in that button. I have created a goal with event in GA. I have Universal GA and I have the standard code. I didnt add nothing to that original universal Analytics code.
I have enable event tracking in that page and add a category name and an action. I also added the iphorm_submit to Element ID as instructed.
Updated the page and then I did a test. I went to GA in events and nothing.
Can you please let me know what am I doing wrong?
My regards,
Pedro Menezes Pereira
Pedro Pereira says
May 20, 2014 at 10:18 pmAddictional information – I have set Element Classname as iphorm-submit-element is that correct?
Thanks!
peter says
May 30, 2014 at 10:15 amHi Pedro,
Have you confirmed that the tracking code is being added by this plugin when checking the element with firebug? (see my example in this article)
Evgeny says
March 2, 2014 at 1:49 pmHi, this one wasn’t answered, so I’m trying again – your plugin works like magic, but it does only for one element on the page. Is it possible to track some more? for example some basic stuff probably anyone will need to track is – a) how many people started to iteract with the form, like onfocus called from one of the input strings, and then how many actually hit submit button.
Is it possible to have two (or more) elements tracked with events in GA?
peter says
March 3, 2014 at 6:06 pmHi Evgeny,
You bring up a good point and unfortunately my plugin handles one element for tracking per page because at the time I wrote it I was only seeking to provide a simple solution.
To make the plugin handle more tracked elements will involve quite a lot of extra coding and time.
I will put this on my TODO list but currently I have other more urgent tasks I need to take care of.
thanks,
Peter
georgina says
August 14, 2013 at 10:57 pmHi, I’d like to use your plugin, however, is it possible to track more than one event on a page/post and if so how do you do this? Many thanks.
David says
May 30, 2013 at 2:24 amHello!
On the bottom of this page, there is a contact form:
http://www.lavidarendezveny.hu/teremberles-arak/
I would like to track event clicking on “Kuldes” button. Checking the code with firebug gives a similar result than yours, but it is not working.
Categories and actions are set in google analytics.
Can you tell me, what should I do?
Thank you!
peter says
May 31, 2013 at 2:48 pmHi David,
I’ve looked at your page and the javascript code appears to be correct.
Have you double checked that you have set up your goals/events correctly in your analytics account?
chris risenhoover says
February 2, 2013 at 9:05 amlove the plugin, I have some custom themes that are building out their own headers. Is there an include I can put in the template to force the check for content experiments so it includes your code? Thanks.
peter says
February 5, 2013 at 11:27 amHi Chris,
The best way would be to use a hook from your theme which pertains to the header.
All well coded themes should have a hook which gets fired when the header is displayed.
See this for an explanation:
http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head
This plugin uses the following line of code to utilize the theme’s hook and display the experiments code in the header:
add_action( ‘wp_head’, array( &$this, ‘output_code’ ), 0 );
Does this answer your question?
cheers,
Peter
NIR says
December 25, 2012 at 8:10 amHi,
Can’t understand something… if I want to check 2 pages, one with green header and one with blue header, how to create the variation page?
If i will create page using WP CMS I will have my default header (green).
Nir
peter says
December 31, 2012 at 12:02 pmHi Nir,
You can achieve this by creating your own WP page template.
To do this you will have to learn about how page templates work. See the wordpress codex (http://codex.wordpress.org/Stepping_Into_Templates)
This tutorial may help too: http://wp.tutsplus.com/tutorials/creative-coding/how-to-include-and-require-files-and-templates-in-wordpress/
Also there may be plugins out there which might do the job for you. I think there are “landing page” plugins you can use to achieve this too.
Thanks,
Peter
Erwin says
December 21, 2012 at 9:21 amHi Peter,
Today I started experimenting with your plugin and the code doesn’t seem to be inserted. I wouldn’t know if this is because I run WP v3.5, as I didn’t have WP Content Experiments and Event Tracking while at v3.4. Amyway, I hope you can verify and test (possibly update).
Thx,
Erwin
peter says
December 22, 2012 at 1:28 pmHi Erwin,
What exactly is not being inserted? The experiments code or the event tracking code?
I have done tests with WP3.5 and I can confirm that all works fine as far as I can see.
Thanks,
Peter
Gürtan says
November 9, 2012 at 9:53 pmHi,
I installed your plugin, but can’t get it to work with my theme. I’m using the ‘Dealers’ plugin. In the default Twenty Eleven theme it works fine. Do you have any suggestions that can let it work? Thank you for your help.
Gürtan says
November 9, 2012 at 9:54 pmI meant ‘Dealers’ theme :)
Gürtan says
November 11, 2012 at 9:05 amHello again,
I discovered the conflict for the plugin to function properly in my theme is in the functions.php file. Do you have any suggestions? Is there perhaps a piece of code missing? Any help would be greatly appreciated.
wpsolhq says
November 12, 2012 at 10:36 amHi Gürtan,
What type of error are you seeing?
thanks,
peter
Bruno says
December 2, 2015 at 11:10 amI only need to track one page, so in my case, this plugin worked like a charm! :)
Thanks!