Web業界ワンピース風相関図(世界編)

四皇

Google
Yahoo
Amazon
Facebook

新世界の強者

Pandora
Myspace
Dropbox
Skype
EverNote
zinga
Quora
Spotify
Groupon
digg

大物ルーキー

Fancy
Flipboard
Path
Pinterest
vimeo
Meet up
Git hub
What's app
Shazam
Food spotting
Hailo
at the pool
dog vacay

GoogleAnalyticsの定期的にチェックする数値

訪問数

サイトを訪れたすべてのユーザーにより開始された個々のセッションの数。
ユーザーがサイトで 30 分以上操作を行なわなかった場合はそれ以降の操作は新しいセッションとみなされる。
1回サイトを離れたユーザーが 30 分以内に同じサイトに戻ってきた場合は同じセッションとして扱われる。
多い方がいい

ユーザー数

特定の期間内にユーザーが初めてサイトに訪問した場合は、訪問、ユーザーともに 1 回ずつ記録されますが、その期間内に再度同じユーザーが訪問した場合は、ユーザー数は 1 回のままで、訪問数は 2 回と記録されます。
多い方がいい

ページビュー数(PV数)

サイトのページが 1 回表示されるごとにカウントされます。
ユーザーがページにアクセスした後でそのページを再度読み込んだ場合、ページビュー数は 1 つ増える。
ユーザーが他のページに移動してから最初のページに戻って来た場合も、そのページの 2 回目の表示は 1 回のページビューとして加算される。
多い方がいい

訪問別ページビュー

ページビュー数÷訪問数
多い方がいい

平均サイト滞在時間

ユーザがサイトを閲覧している平均の時間
長いほどいい

直帰率

1ページのみ閲覧した訪問の割合
低いほどいい30%台が望ましい

新規訪問の割合

初めてサイトを訪問したユーザーの新規訪問数の割合。

Google Places Autocomplete Apiを使ってみた

Google Places Autocomplete
https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete

Airbnbなので使われている
https://www.airbnb.jp/
世界の地域名が簡単に取得できて便利

サンプルコード

<!DOCTYPE html>
<html>
  <head>
    <title>Places Autocomplete</title>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <link href="/maps/documentation/javascript/examples/default.css" rel="stylesheet">
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>

    <style>
      input {
        border: 1px solid  rgba(0, 0, 0, 0.5);
      }
      input.notfound {
        border: 2px solid  rgba(255, 0, 0, 0.4);
      }
    </style>

    <script>
function initialize() {
  var mapOptions = {
    center: new google.maps.LatLng(-33.8688, 151.2195),
    zoom: 13,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(document.getElementById('map-canvas'),
    mapOptions);

  var input = /** @type {HTMLInputElement} */(document.getElementById('searchTextField'));
  var autocomplete = new google.maps.places.Autocomplete(input);

  autocomplete.bindTo('bounds', map);

  var infowindow = new google.maps.InfoWindow();
  var marker = new google.maps.Marker({
    map: map
  });

  google.maps.event.addListener(autocomplete, 'place_changed', function() {
    infowindow.close();
    marker.setVisible(false);
    input.className = '';
    var place = autocomplete.getPlace();
    if (!place.geometry) {
      // Inform the user that the place was not found and return.
      input.className = 'notfound';
      return;
    }

    // If the place has a geometry, then present it on a map.
    if (place.geometry.viewport) {
      map.fitBounds(place.geometry.viewport);
    } else {
      map.setCenter(place.geometry.location);
      map.setZoom(17);  // Why 17? Because it looks good.
    }
    marker.setIcon(/** @type {google.maps.Icon} */({
      url: place.icon,
      size: new google.maps.Size(71, 71),
      origin: new google.maps.Point(0, 0),
      anchor: new google.maps.Point(17, 34),
      scaledSize: new google.maps.Size(35, 35)
    }));
    marker.setPosition(place.geometry.location);
    marker.setVisible(true);

    var address = '';
    if (place.address_components) {
      address = [
        (place.address_components[0] && place.address_components[0].short_name || ''),
        (place.address_components[1] && place.address_components[1].short_name || ''),
        (place.address_components[2] && place.address_components[2].short_name || '')
      ].join(' ');
    }

    infowindow.setContent('<div><strong>' + place.name + '</strong><br>' + address);
    infowindow.open(map, marker);
  });

  // Sets a listener on a radio button to change the filter type on Places
  // Autocomplete.
  function setupClickListener(id, types) {
    var radioButton = document.getElementById(id);
    google.maps.event.addDomListener(radioButton, 'click', function() {
      autocomplete.setTypes(types);
    });
  }

  setupClickListener('changetype-all', []);
  setupClickListener('changetype-establishment', ['establishment']);
  setupClickListener('changetype-geocode', ['geocode']);
}

google.maps.event.addDomListener(window, 'load', initialize);

    </script>
  </head>
  <body>
    <div id="panel" >
      <input id="searchTextField" type="text" size="50">
      <input type="radio" name="type" id="changetype-all" checked="checked">
      <label for="changetype-all">All</label>

      <input type="radio" name="type" id="changetype-establishment">
      <label for="changetype-establishment">Establishments</label>

      <input type="radio" name="type" id="changetype-geocode">
      <label for="changetype-geocode">Geocodes</lable>
    </div>
    <div id="map-canvas"></div>
  </body>
</html>

RailsでFacebookログイン

1.OmniAuthをインストール

gem 'omniauth'

2.Facebook Developer登録

https://developers.facebook.com/apps
⇒新しいアプリを作成
⇒URLはHerokuなどで生成
https://www.heroku.com/

3.FacebookAPIキー設定

/config/initializers/omniauth.rb

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :twitter,"Consumer key","Consumer secret"
  provider :facebook,"App ID","App Secret"
end

herokuの使い方

1.herokuとは

Heroku は Ruby / Rails をクラウド上で
動かすことのできるホスティングサービス。
PaaS(Platform as a Service)

2.インストール

gem install heroku

3.Herokuのサイトでユーザ登録

https://www.heroku.com/

4.ローカルでアプリの作成

rails new [app_name]
cd [app_name]
git init
git add .
git commit

5.Herokuにデプロイする

heroku create [heroku_app_name]
# git clone とかして持ってきたときには明示的に追加する
# git remote add heroku git@heroku.com:[heroku_app_name].git 
git push heroku master

6.Heroku実行

heroku open

ブラウザが自動で開いてHerokuに登録しアプリが実行されます。