Skip to content

Instantly share code, notes, and snippets.

View strategyst's full-sized avatar

Daniel Lee strategyst

View GitHub Profile
<!-- Load the Content Experiment JavaScript API client for the experiment -->
<script src="//www.google-analytics.com/cx/api.js?experiment=YOUR_EXPERIMENT_ID"></script>
<script>
// Ask Google Analytics which variation to show the user.
var chosenVariation = cxApi.chooseVariation();
</script>
/**
* Add GA Content Experiments Scripts Here
*/
function content_experiments_head_script() {
if(is_page(2)) { ?>
<?php }
/**
* Add GA Content Experiments Scripts Here
*/
function content_experiments_head_script() {
// Replace '2' with the post/page ID of the original version of the page you are testing
if(is_page(2)) { ?>
<!-- Load the Content Experiment JavaScript API client for the experiment -->
<script src="//www.google-analytics.com/cx/api.js?experiment=YOUR_EXPERIMENT_ID"></script>
/**
* Add GA Content Experiments Scripts Here
*/
function content_experiments_head_script() {
// Replace '2' with the post/page ID of the original version of the page you are testing
if(is_page(2)) { ?>
<!-- Load the Content Experiment JavaScript API client for the experiment -->
<script src="//www.google-analytics.com/cx/api.js?experiment=YOUR_EXPERIMENT_ID"></script>
<?php
add_action('wp_head', 'schema_wp_head');
function schema_wp_head(){
$schema = get_post_meta(get_the_ID(), 'schema', true);
if(!empty($schema)) {
echo $schema;
}
}