This repository has been archived by the owner on Sep 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from optimizely/headline-testing
Headline testing via Experiment API
- Loading branch information
Showing
9 changed files
with
544 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Javascript for plugin settings page | ||
|
||
function optimizelyConfigPage() { | ||
var $ = jQuery; | ||
|
||
/* | ||
AUTHENTICATION W/ OPTIMIZELY | ||
When the user presses the button, we call the GET projects/ endpoint to list out all the projects in their account. For each project, we show its name in the dropdown and store its ID in the value attribute for submission to a form. | ||
*/ | ||
|
||
$("button#connect_optimizely").click(function(event) { | ||
event.preventDefault(); | ||
$("#project_id").html("<option>Loading projects...</option>"); | ||
|
||
optly = new OptimizelyAPI($("#token").val()); | ||
|
||
optly.get('projects', function(response) { | ||
$("#project_id").empty(); | ||
|
||
$.each(response, function(key, val) { | ||
$("#project_id").append("<option value='" + val.id + "'>" + val.project_name + "</option>"); | ||
}); | ||
|
||
$("#project_id").change(); // update project code w/ the default value | ||
}); | ||
|
||
/* | ||
CHOOSING A PROJECT | ||
When the user selects a project from the dropdown, we populate the project code box with the Optimizely snippet for that project ID. | ||
*/ | ||
$('#project_id').change(function() { | ||
var id = $('#project_id').val(); | ||
var name = $('#project_id option:selected').text(); | ||
var project_code = '<script src="//cdn.optimizely.com/js/' + id + '.js"></script>'; | ||
$('#project_code').text(project_code); | ||
$('#project_name').val(name); | ||
}); | ||
|
||
|
||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<div class="wrap"> | ||
<h2><?php _e('Optimizely Configuration'); ?></h2> | ||
<div class="narrow"> | ||
<form action="" method="post" id="optimizely-conf"> | ||
<?php optimizely_nonce_field($optimizely_nonce) ?> | ||
<h3>About Optimizely</h3> | ||
<p>Simple, fast, and powerful. <a href="http://www.optimizely.com" target="_blank">Optimizely</a> is a dramatically easier way for you to improve your website through A/B testing. Create an experiment in minutes with absolutely no coding or engineering required. Convert your website visitors into customers and earn more revenue: create an account at <a href="http://www.optimizely.com" target="_blank">optimizely.com</a> and start A/B testing today!</p> | ||
<h3>Optimizely API tokens</h3> | ||
<p>Once you create an account, you can find your API Token on your account page at <a href="https://www.optimizely.com/account">optimizely.com/account</a>. | ||
<p> | ||
<label for="token"><strong>API Token</strong></label> | ||
<br /> | ||
<input id="token" name="token" type="text" maxlength="80" value="<?= get_option('optimizely_token'); ?>" class="code" /> | ||
</p> | ||
|
||
<button id="connect_optimizely" class="button">Connect Optimizely</button> | ||
|
||
<h3>Choose a Project</h3> | ||
<input type="hidden" id="project_name" name="project_name" value="<?= get_option('optimizely_project_name') ?>" /> | ||
<select id="project_id" name="project_id"> | ||
<?php if (get_option('optimizely_project_id')) { ?> | ||
<option value="<?= get_option('optimizely_project_id') ?>" selected><?= get_option('optimizely_project_name') ?></option> | ||
<?php } ?> | ||
<option value="">Connect Optimizely to choose a project...</option> | ||
</select> | ||
<p>Optimizely will add the following project code to your page automatically:</p> | ||
<textarea class="code" id="project_code" name="project_code" readonly><?= get_option('optimizely_project_code') ?></textarea> | ||
|
||
|
||
<h3>Variation Code</h3> | ||
<p>Optimizely will use this variation code to change headlines on your site. We've provided code that works with the default theme, but you might want to add or change it to work with your themes and plugins.</p> | ||
|
||
<textarea class="code" rows="5" name="variation_template" id="variation_template"><?= get_option('optimizely_variation_template') ?></textarea> | ||
|
||
<p>You can use the variables $POST_ID, $OLD_TITLE, and $NEW_TITLE in your code.</p> | ||
|
||
<p class="submit"><input type="submit" name="submit" value="<?php _e('Submit »'); ?>" class="button-primary" /></p> | ||
|
||
|
||
</form> | ||
<script type="text/javascript"> | ||
optimizelyConfigPage(); | ||
</script> | ||
|
||
|
||
|
||
</div> | ||
</div> |
Oops, something went wrong.