Skip to content

Instantly share code, notes, and snippets.

Created April 19, 2014 14:29
Show Gist options
  • Save gcchaan/11086046 to your computer and use it in GitHub Desktop.
Save gcchaan/11086046 to your computer and use it in GitHub Desktop.
measure of effect for website
<!DOCTYPE html>
<html lang="ja">
<meta charset="utf-8" />
<script src="../jquery-2.0.3.min.js"></script>
function getRound(num,m){
num *= Math.pow(10,m);
num = Math.round(num);
return (num / Math.pow(10,m)).toFixed(m);
$('#MoE [name="submit"]').click(function(){
var cost = $('#cost').val();
var pv = $('#pv').val();
var cpp = $('#cpp').val();
var ctr = $('#ctr').val();
var ct = $('#ct').val();
var cpc = $('#cpc').val();
var cvr = $('#cvr').val();
var cv = $('#cv').val();
var cpa = $('#cpa').val();
if (!cost){
cost = (pv>0 && cpp>0) ? getRound(pv * cpp,1) : getRound(ct * cpc,1);
cpp = getRound(cost / pv,2);
ctr>0 ? ct = getRound(pv * ctr,1) : ctr = getRound(ct / pv,1);
cpc = getRound(cost / ct,1);
cvr ? cv = getRound(ct * cvr,1) : cvr = getRound(cv / ct,1);
cpa = getRound(cost / cv,1);
<form id="MoE">
<label for="cost">広告費</label><input type="text" name="cost" id="cost">
<label for="pv">PV</label><input type="text" name="pv" id="pv">
<label for="cpp">PV単価</label><input type="text" name="cpp" id="cpp">
<label for="ctr">CTR</label><input type="text" name="ctr" id="ctr">
<label for="ct">CT</label><input type="text" name="ct" id="ct">
<label for="cpc">CPC</label><input type="text" name="cpc" id="cpc">
<label for="cvr">CVR</label><input type="text" name="cvr" id="cvr">
<label for="cv">CV</label><input type="text" name="cv" id="cv">
<label for="cpa">CPA</label><input type="text" name="cpa" id="cpa">
<input type="button" name="submit" value="submit!">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment