LoginSignup
5
5

More than 5 years have passed since last update.

jsでワンメトリクス(たった一つの指標)を求める

Posted at

ワンメトリクス(たった一つの指標)

2014年にSEOで有名なmozブログにワンメトリクス(たった一つの指標)についての記事があります。

該当記事URL: https://moz.com/blog/one-metric

もう2015年末ですが、この記事が公開された時にjavascriptでさっと実装したのでその紹介です。詳細については2015年にウェブ担で翻訳された記事を見る方が分かり易いです。

jsfiddleでのデモ

このワンメトリクス算出の試せるデモをjsfiddleに設置しました。scoresの所をPVやセッションに読み替えると「なるほど」とイメージできるかと思います。

ワンメトリクスを求めるScoring#scoreの使い方

使い方は単純で値の入った配列をクラス生成時に渡すだけです。後はScoring#score(value)でワンメトリクスが帰ってきます。

var scores = [100, 80, 60, 40, 20, 0];
var scoring = new Scoring(scores);

$("#score1").html(scoring.score(scores[0])); // return -> 100.48863977235504
$("#score2").html(scoring.score(scores[1])); // return -> 84.20031393529594
$("#score3").html(scoring.score(scores[2])); // return -> 63.24648099782308
$("#score4").html(scoring.score(scores[3])); // return -> 33.83153079050539
$("#score5").html(scoring.score(scores[4])); // return -> -15.946724434026365

Javascriptでの実装の説明

以下ワンメトリクスを実装したjavascriptのコードです。jQueryを使っています。

/**
 *  Implemented the "Convert it to the One Metric score".  
 *  -> http://moz.com/blog/one-metric
 *  
 * usage:
 *  var scores = [100, 80, 60, 40, 20, 0];
 *  var scoring = new Scoring(scores);
 *  scoring.score(scores[3]); //
 */
$(function(){
  Scoring = function(scores) {
    this.init(scores);
  };
  $.extend(Scoring.prototype, {
    scores: [],
    average: 0,
    coefficient: 0,
    init: function(scores) {
      this.scores = scores;
      this.offset = 1.0 + this.scores.length / 2; // 0でinfinityを回避するため
      this.average = this.calculateAverage();
      this.coefficient = this.calculateCoefficient();
    },
    score: function(v) {
      var x = ((this.offset / this.scores.length) + v) / this.average;
      var a = 50 + Math.log(x) * this.coefficient;
      return a;
    },
    calculateAverage: function() {
      var total = this.offset;
      $.each(this.scores, function() {
        total += this;
      });
      return total / this.scores.length;
    },
    calculateCoefficient: function() {
      var max = Math.max.apply(null, this.scores);
      var upvLog = Math.log(max / this.average); // 自然対数を使う
      return 50 / upvLog;
    },
  });
});

係数を求める #calculateCoefficient かその係数を使う #score が使う人によって手を加える所になります。上記コードでは自然対数をそのまま利用しています。

ワンメトリクスを使うメリット

ぼくは仕事で技術面に特化したSEOをしているので、こういった記事で書かれている事を実際に試して見たりプログラムをさっと書いて良さそうだったらツールに組み込んだりといった事をしています。

このワンメトリクスのように複数の数値を組み合わせ1つの相対的な数値として指標化すると格段に分かり易くなります。5教科を合わせた偏差値のようなもので、総合点で見ると順位付けもやり易くなります。

最近流行しているクラウドベースのBIツール(ビジネスインテリジェンス)やMAツール(マーケティングオートメーション)ではこういったワンメトリクス化された指標が多く使われていますよね。

そこまで難しくない事が多い

これはmozブログであった内容を実装したものですが、SEO関連記事やSlideShareの資料ではなんだか難しいそうな数式が出てきたりデータ取得ツールの話が出てくる事が良くあります。

難しそうに見えるだけで実際に試して見るとそこまで難しくない事が多いので自分たちで試して見るか、もしくはSEOやアクセス解析はコンサルが入っている事も良くあるのでそのコンサルの人に依頼してやってみてもらうのも良いと思います。

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5